@kjerneverk/execution-openai 1.0.5-dev.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.
Files changed (50) hide show
  1. package/.kodrdriv-test-cache.json +6 -0
  2. package/LICENSE +18 -0
  3. package/README.md +80 -0
  4. package/dist/index.d.ts +85 -0
  5. package/dist/index.js +103 -0
  6. package/dist/index.js.map +1 -0
  7. package/output/kodrdriv/.kodrdriv-parallel-context.json +589 -0
  8. package/output/kodrdriv/260110-1751-release-notes.md +39 -0
  9. package/output/kodrdriv/260112-2207-commit-message.md +1 -0
  10. package/output/kodrdriv/260112-2208-release-notes.md +36 -0
  11. package/output/kodrdriv/260112-2341-commit-message.md +1 -0
  12. package/output/kodrdriv/260113-0029-commit-message.md +1 -0
  13. package/output/kodrdriv/260113-0030-release-notes.md +5 -0
  14. package/output/kodrdriv/260114-0656-commit-message.md +6 -0
  15. package/output/kodrdriv/260115-0616-commit-message.md +1 -0
  16. package/output/kodrdriv/260115-0739-commit-message.md +1 -0
  17. package/output/kodrdriv/260126-0852-commit-message.md +1 -0
  18. package/output/kodrdriv/260126-0853-release-notes.md +47 -0
  19. package/output/kodrdriv/260126-0854-release-notes.md +50 -0
  20. package/output/kodrdriv/260128-0929-commit-message.md +1 -0
  21. package/output/kodrdriv/260128-0929-release-notes.md +24 -0
  22. package/output/kodrdriv/260128-0959-commit-message.md +6 -0
  23. package/output/kodrdriv/260128-1127-commit-message.md +1 -0
  24. package/output/kodrdriv/260128-1127-release-notes.md +30 -0
  25. package/output/kodrdriv/260130-1639-commit-message.md +5 -0
  26. package/output/kodrdriv/260130-1652-commit-message.md +1 -0
  27. package/output/kodrdriv/260130-1652-release-notes.md +27 -0
  28. package/output/kodrdriv/RELEASE_NOTES.md +25 -0
  29. package/output/kodrdriv/RELEASE_TITLE.md +1 -0
  30. package/output/kodrdriv/agentic-reflection-commit-2026-01-13T06-07-12-251Z.md +97 -0
  31. package/output/kodrdriv/agentic-reflection-commit-2026-01-13T07-41-08-151Z.md +97 -0
  32. package/output/kodrdriv/agentic-reflection-commit-2026-01-13T08-29-26-449Z.md +97 -0
  33. package/output/kodrdriv/agentic-reflection-commit-2026-01-14T14-56-03-314Z.md +102 -0
  34. package/output/kodrdriv/agentic-reflection-commit-2026-01-15T14-16-42-406Z.md +97 -0
  35. package/output/kodrdriv/agentic-reflection-commit-2026-01-15T15-39-56-545Z.md +114 -0
  36. package/output/kodrdriv/agentic-reflection-commit-2026-01-26T16-52-42-503Z.md +152 -0
  37. package/output/kodrdriv/agentic-reflection-commit-2026-01-28T17-59-30-913Z.md +204 -0
  38. package/output/kodrdriv/agentic-reflection-commit-2026-01-31T00-39-30-443Z.md +245 -0
  39. package/output/kodrdriv/agentic-reflection-commit-2026-01-31T00-52-07-165Z.md +152 -0
  40. package/output/kodrdriv/agentic-reflection-release-2026-01-11T01-51-19-115Z.md +277 -0
  41. package/output/kodrdriv/agentic-reflection-release-2026-01-13T06-08-15-507Z.md +289 -0
  42. package/output/kodrdriv/agentic-reflection-release-2026-01-13T08-30-05-728Z.md +312 -0
  43. package/output/kodrdriv/agentic-reflection-release-2026-01-26T16-53-34-128Z.md +417 -0
  44. package/output/kodrdriv/agentic-reflection-release-2026-01-26T16-53-55-634Z.md +391 -0
  45. package/output/kodrdriv/agentic-reflection-release-2026-01-26T16-54-13-700Z.md +456 -0
  46. package/output/kodrdriv/agentic-reflection-release-2026-01-26T16-54-22-655Z.md +496 -0
  47. package/output/kodrdriv/agentic-reflection-release-2026-01-26T16-54-32-261Z.md +490 -0
  48. package/output/kodrdriv/agentic-reflection-release-2026-01-31T00-52-29-053Z.md +334 -0
  49. package/package.json +58 -0
  50. package/package.json~ +57 -0
@@ -0,0 +1,334 @@
1
+ # Agentic Workflow - Self-Reflection Report
2
+
3
+ Generated: 2026-01-31T00:52:29.053Z
4
+
5
+ ## Execution Summary
6
+
7
+ - **Iterations**: 5
8
+ - **Tool Calls**: 14
9
+ - **Unique Tools**: 10
10
+
11
+ ## Tool Effectiveness Analysis
12
+
13
+ | Tool | Calls | Success | Failures | Success Rate | Avg Duration |
14
+ |------|-------|---------|----------|--------------|--------------|
15
+ | get_file_content | 4 | 4 | 0 | 100.0% | 1ms |
16
+ | search_codebase | 2 | 2 | 0 | 100.0% | 12ms |
17
+ | get_release_stats | 1 | 1 | 0 | 100.0% | 37ms |
18
+ | get_tag_history | 1 | 1 | 0 | 100.0% | 67ms |
19
+ | analyze_commit_patterns | 1 | 1 | 0 | 100.0% | 7ms |
20
+ | get_breaking_changes | 1 | 1 | 0 | 100.0% | 20ms |
21
+ | group_files_by_concern | 1 | 1 | 0 | 100.0% | 0ms |
22
+ | compare_previous_release | 1 | 1 | 0 | 100.0% | 39ms |
23
+ | get_file_dependencies | 1 | 1 | 0 | 100.0% | 32ms |
24
+ | get_related_tests | 1 | 1 | 0 | 100.0% | 0ms |
25
+
26
+ ### Tool Performance Insights
27
+
28
+ **Most Frequently Used:**
29
+ - get_release_stats: 1 calls
30
+ - get_tag_history: 1 calls
31
+ - analyze_commit_patterns: 1 calls
32
+
33
+ ## Recommendations for Improvement
34
+
35
+ - **Underutilized Tools**: Many tools were called only once. Consider whether all tools are necessary or if the agent needs better guidance on when to use them.
36
+
37
+ ## Detailed Execution Timeline
38
+
39
+ | Time | Iteration | Tool | Result | Duration |
40
+ |------|-----------|------|--------|----------|
41
+ | 4:52:12 PM | 1 | get_release_stats | ✅ Success | 37ms |
42
+ | 4:52:12 PM | 1 | get_tag_history | ✅ Success | 67ms |
43
+ | 4:52:12 PM | 1 | analyze_commit_patterns | ✅ Success | 7ms |
44
+ | 4:52:12 PM | 1 | get_breaking_changes | ✅ Success | 20ms |
45
+ | 4:52:15 PM | 2 | group_files_by_concern | ✅ Success | 0ms |
46
+ | 4:52:15 PM | 2 | get_file_content | ✅ Success | 1ms |
47
+ | 4:52:15 PM | 2 | get_file_content | ✅ Success | 0ms |
48
+ | 4:52:15 PM | 2 | get_file_content | ✅ Success | 1ms |
49
+ | 4:52:15 PM | 2 | compare_previous_release | ✅ Success | 39ms |
50
+ | 4:52:17 PM | 3 | search_codebase | ✅ Success | 14ms |
51
+ | 4:52:17 PM | 3 | search_codebase | ✅ Success | 9ms |
52
+ | 4:52:17 PM | 3 | get_file_dependencies | ✅ Success | 32ms |
53
+ | 4:52:17 PM | 3 | get_related_tests | ✅ Success | 0ms |
54
+ | 4:52:18 PM | 4 | get_file_content | ✅ Success | 1ms |
55
+
56
+ ## Conversation History
57
+
58
+ <details>
59
+ <summary>Click to expand full agentic interaction</summary>
60
+
61
+ ```json
62
+ [
63
+ {
64
+ "role": "system",
65
+ "content": "You are a professional software engineer writing release notes for your team and users.\n\n## Available Tools\n\nYou have access to tools to investigate the release:\n- `get_tag_history` - Understand release patterns\n- `get_release_stats` - Quantify scope of changes\n- `compare_previous_release` - See how this compares to previous releases\n- `group_files_by_concern` - Identify themes in changes\n- `analyze_commit_patterns` - Detect patterns in commits\n- `get_file_content` - Read file contents or diffs\n- `analyze_diff_section` - Expand unclear changes\n- `get_file_history` - Understand how code evolved\n- `get_file_dependencies` - Assess impact and reach\n- `search_codebase` - Find usage patterns\n- `get_related_tests` - Understand behavior changes\n- `get_breaking_changes` - Identify breaking changes (always use this)\n\nUse these tools to investigate the changes rather than asking for information upfront.\n\n## Your Task\n\nWrite release notes that clearly explain what's in this release and why it matters. Your notes should help users and developers understand what changed without needing to read every commit.\n\nFocus on:\n- What problems does this release solve?\n- What new capabilities does it add?\n- What's the impact on users and developers?\n- Are there breaking changes or important considerations?\n\nUse the available tools to investigate the changes. The more you understand, the better your notes will be.\n\n**Important**: If additional context is provided (from context files or other sources), use your judgment:\n- If the context is relevant to this specific package/release, incorporate it appropriately\n- If the context describes changes in other packages or unrelated work, ignore it\n- Don't fabricate connections between this package and unrelated context\n- Be honest about what changed - only mention what actually happened in this release\n- Context is supplemental information, not a requirement to include\n\n## Investigation Approach\n\nUse tools based on what you need to know:\n\n**Context:**\n- get_tag_history - understand release patterns\n- get_release_stats - quantify scope\n- compare_previous_release - see how this compares\n\n**Understanding:**\n- group_files_by_concern - identify themes\n- analyze_commit_patterns - detect patterns\n- get_file_content - see full context\n- analyze_diff_section - expand unclear changes\n- get_file_history - understand evolution\n\n**Impact:**\n- get_file_dependencies - assess reach\n- search_codebase - find usage patterns\n- get_related_tests - understand behavior changes\n- get_breaking_changes - identify breaking changes (always use)\n\n## Writing Style\n\nWrite naturally and directly:\n- Use plain language that users can understand\n- Be specific about what changed and why\n- Avoid marketing speak and buzzwords\n- No emojis or excessive punctuation\n- No phrases like \"we're excited to announce\"\n- No meta-commentary about the release itself\n- Focus on facts and implications, not enthusiasm\n\nStructure your notes logically:\n- Start with the most important changes\n- Group related changes together\n- Explain breaking changes clearly\n- Include practical examples when helpful\n\n## Output Format\n\nWhen ready, output your release notes in this exact format:\n\nRELEASE_TITLE:\n[A clear, factual title describing the main changes]\n\nRELEASE_BODY:\n[Detailed release notes in Markdown format]\n\nDo not include any JSON, code blocks, or wrapper syntax. Output plain text and markdown only.\nNo conversational remarks or follow-up offers."
66
+ },
67
+ {
68
+ "role": "user",
69
+ "content": "I need comprehensive release notes for changes from main to HEAD.\n\n**CRITICAL VERSION INSTRUCTION: This is a release for version 1.0.4. You MUST use EXACTLY \"1.0.4\" in your release title. DO NOT use any development/prerelease version numbers you may see in the diff (like 1.0.4-dev.0 or similar). The release version is 1.0.4.**\n\n## Your Analysis Task\n\nUse your tools to investigate the changes between main and HEAD:\n1. Use `get_release_stats` to understand the scope of changes\n2. Use `get_tag_history` or `compare_previous_release` to see release patterns\n3. Use `analyze_commit_patterns` to detect themes\n4. Use `group_files_by_concern` to identify logical groupings\n5. Use `get_breaking_changes` to identify breaking changes (always check this)\n6. Use `get_file_content` or `analyze_diff_section` to understand specific changes\n7. Use `get_file_dependencies` and `search_codebase` to assess impact\n\nWrite clear release notes that answer:\n- What's the main story of this release?\n- What problems does it solve?\n- What's the impact on users and developers?\n- Are there breaking changes?\n\nIf context information is provided, use it only if relevant to this specific package.\nDon't force connections that don't exist - if context describes changes in other packages\nor unrelated features, simply ignore it and focus on what actually changed in this release.\n\nStart by gathering statistics and understanding the scope, then investigate specific changes as needed."
70
+ },
71
+ {
72
+ "role": "assistant",
73
+ "content": null,
74
+ "tool_calls": [
75
+ {
76
+ "id": "call_za4rI3GoggX4RHDbh7J6tANm",
77
+ "type": "function",
78
+ "function": {
79
+ "name": "get_release_stats",
80
+ "arguments": "{\"fromRef\": \"main\", \"toRef\": \"HEAD\"}"
81
+ }
82
+ },
83
+ {
84
+ "id": "call_GGs9nZTsfc6x0DDt2ZJSGBpV",
85
+ "type": "function",
86
+ "function": {
87
+ "name": "get_tag_history",
88
+ "arguments": "{\"limit\": 20, \"pattern\": \"v*\"}"
89
+ }
90
+ },
91
+ {
92
+ "id": "call_6zakdefkv4LBbJllyxCnyA2t",
93
+ "type": "function",
94
+ "function": {
95
+ "name": "analyze_commit_patterns",
96
+ "arguments": "{\"fromRef\": \"main\", \"toRef\": \"HEAD\"}"
97
+ }
98
+ },
99
+ {
100
+ "id": "call_qwwH5WN89CdiufDGAI0o7vxd",
101
+ "type": "function",
102
+ "function": {
103
+ "name": "get_breaking_changes",
104
+ "arguments": "{\"fromRef\": \"main\", \"toRef\": \"HEAD\"}"
105
+ }
106
+ }
107
+ ]
108
+ },
109
+ {
110
+ "role": "tool",
111
+ "tool_call_id": "call_za4rI3GoggX4RHDbh7J6tANm",
112
+ "content": "Total commits: 3\n\nContributors:\n 3\tTim O'Brien\n\n\nFile changes: 3 files changed, 7 insertions(+), 7 deletions(-)\n\nTop 10 most changed files:\n vite.config.ts | 4 ++--\n src/index.ts | 4 ++--\n package.json | 6 +++---\n 3 files changed, 7 insertions(+), 7 deletions(-)\n",
113
+ "name": "get_release_stats"
114
+ },
115
+ {
116
+ "role": "tool",
117
+ "tool_call_id": "call_GGs9nZTsfc6x0DDt2ZJSGBpV",
118
+ "content": "Recent release tags:\nv1.0.3: 2026-01-28 11:27:51 -0800 - feat(openai): add model-aware provider and sanitize OpenAI secrets\nv1.0.1: 2026-01-28 09:29:35 -0800 - fix: add npm tag detection for prerelease versions in publish workflow (#14)\nv1.0.0: 2026-01-26 08:55:12 -0800 - chore(release): bump @riotprompt/execution-openai to 1.0.0 (#13)\nv0.0.4: 2026-01-13 00:30:54 -0800 - chore(release): bump @riotprompt/execution-openai to 0.0.4 (#7)\nv0.0.3: 2026-01-12 22:09:39 -0800 - chore(release): bump @riotprompt/execution-openai to 0.0.3 (#6)\nv0.0.3-dev.0: tag v0.0.3-dev.0\nTagger: Tim O'Brien <tobrien@discursive.com>\n\n0.0.3-dev.0\n2026-01-10 17:54:34 -0800 - 0.0.3-dev.0\nv0.0.2: 2026-01-10 17:51:23 -0800 - Updated and separated tests (#5)\nv0.0.2-dev.0: tag v0.0.2-dev.0\nTagger: Tim O'Brien <tobrien@discursive.com>\n\n0.0.2-dev.0\n2026-01-10 11:22:13 -0800 - 0.0.2-dev.0",
119
+ "name": "get_tag_history"
120
+ },
121
+ {
122
+ "role": "tool",
123
+ "tool_call_id": "call_6zakdefkv4LBbJllyxCnyA2t",
124
+ "content": "Commit types:\n chore: 2\n feat: 1\n\nTop keywords in commits:\n chore: 2\n release: 1\n openai: 1\n inline: 1\n execution: 1\n types: 1\n harden: 1\n secret: 1\n error: 1\n sanitization: 1",
125
+ "name": "analyze_commit_patterns"
126
+ },
127
+ {
128
+ "role": "tool",
129
+ "tool_call_id": "call_qwwH5WN89CdiufDGAI0o7vxd",
130
+ "content": "No obvious breaking changes detected. Manual review recommended for API changes.",
131
+ "name": "get_breaking_changes"
132
+ },
133
+ {
134
+ "role": "assistant",
135
+ "content": null,
136
+ "tool_calls": [
137
+ {
138
+ "id": "call_r3p23m6kWPywLjIlcWSFxY6c",
139
+ "type": "function",
140
+ "function": {
141
+ "name": "group_files_by_concern",
142
+ "arguments": "{\"filePaths\": [\"vite.config.ts\", \"src/index.ts\", \"package.json\"]}"
143
+ }
144
+ },
145
+ {
146
+ "id": "call_pZBb9yPUvCHmtHBQNnVyiZbd",
147
+ "type": "function",
148
+ "function": {
149
+ "name": "get_file_content",
150
+ "arguments": "{\"filePath\": \"package.json\", \"includeLineNumbers\": true}"
151
+ }
152
+ },
153
+ {
154
+ "id": "call_B2xwoEI1OQr8xh3KyFrzkMNv",
155
+ "type": "function",
156
+ "function": {
157
+ "name": "get_file_content",
158
+ "arguments": "{\"filePath\": \"src/index.ts\", \"includeLineNumbers\": true}"
159
+ }
160
+ },
161
+ {
162
+ "id": "call_RHnlsunxSW2irxkHET6ifYFR",
163
+ "type": "function",
164
+ "function": {
165
+ "name": "get_file_content",
166
+ "arguments": "{\"filePath\": \"vite.config.ts\", \"includeLineNumbers\": true}"
167
+ }
168
+ },
169
+ {
170
+ "id": "call_iVrnJuyXEpyUykRHughtBW1Q",
171
+ "type": "function",
172
+ "function": {
173
+ "name": "compare_previous_release",
174
+ "arguments": "{\"previousTag\": \"v1.0.3\", \"currentRef\": \"HEAD\", \"statsOnly\": false}"
175
+ }
176
+ }
177
+ ]
178
+ },
179
+ {
180
+ "role": "tool",
181
+ "tool_call_id": "call_r3p23m6kWPywLjIlcWSFxY6c",
182
+ "content": "other (1 files):\n - vite.config.ts\n\nsource:src (1 files):\n - src/index.ts\n\ndependencies (1 files):\n - package.json\n\nSuggestion: These 3 groups represent different concerns in the release.",
183
+ "name": "group_files_by_concern"
184
+ },
185
+ {
186
+ "role": "tool",
187
+ "tool_call_id": "call_pZBb9yPUvCHmtHBQNnVyiZbd",
188
+ "content": "1: {\n2: \"name\": \"@riotprompt/execution-openai\",\n3: \"version\": \"1.0.4\",\n4: \"description\": \"OpenAI provider for execution - implements Provider interface\",\n5: \"type\": \"module\",\n6: \"main\": \"./dist/index.js\",\n7: \"types\": \"./dist/index.d.ts\",\n8: \"exports\": {\n9: \".\": {\n10: \"types\": \"./dist/index.d.ts\",\n11: \"import\": \"./dist/index.js\"\n12: }\n13: },\n14: \"engines\": {\n15: \"node\": \">=24.0.0\"\n16: },\n17: \"scripts\": {\n18: \"clean\": \"rm -rf dist\",\n19: \"build\": \"vite build\",\n20: \"test\": \"vitest run --coverage\",\n21: \"test:coverage\": \"vitest run --coverage\",\n22: \"lint\": \"eslint src\",\n23: \"precommit\": \"npm run build && npm run lint && npm run test\",\n24: \"prepublishOnly\": \"npm run clean && npm run build\"\n25: },\n26: \"keywords\": [\n27: \"llm\",\n28: \"openai\",\n29: \"gpt\",\n30: \"execution\",\n31: \"provider\"\n32: ],\n33: \"author\": \"Tim O'Brien <tobrien@discursive.com>\",\n34: \"license\": \"Apache-2.0\",\n35: \"repository\": {\n36: \"type\": \"git\",\n37: \"url\": \"https://github.com/kjerneverk/execution-openai\"\n38: },\n39: \"dependencies\": {\n40: \"@utilarium/offrecord\": \"^0.0.3\",\n41: \"@utilarium/spotclean\": \"^0.0.4\",\n42: \"openai\": \"^6.16.0\",\n43: \"tiktoken\": \"^1.0.21\"\n44: },\n45: \"devDependencies\": {\n46: \"@types/node\": \"^25.0.6\",\n47: \"@typescript-eslint/eslint-plugin\": \"^8.33.1\",\n48: \"@typescript-eslint/parser\": \"^8.33.1\",\n49: \"@vitest/coverage-v8\": \"^4.0.18\",\n50: \"ajv\": \"^8.17.1\",\n51: \"eslint\": \"^9.28.0\",\n52: \"globals\": \"^17.2.0\",\n53: \"typescript\": \"^5.8.3\",\n54: \"vite\": \"^7.0.4\",\n55: \"vite-plugin-dts\": \"^4.5.4\",\n56: \"vitest\": \"^4.0.18\"\n57: }\n58: }\n59: ",
189
+ "name": "get_file_content"
190
+ },
191
+ {
192
+ "role": "tool",
193
+ "tool_call_id": "call_B2xwoEI1OQr8xh3KyFrzkMNv",
194
+ "content": "1: /**\n2: * Execution OpenAI Package\n3: *\n4: * OpenAI provider implementation for LLM execution.\n5: *\n6: * @packageDocumentation\n7: */\n8: \n9: import OpenAI from 'openai';\n10: import { getRedactor } from '@utilarium/offrecord';\n11: import { \n12: createSafeError, \n13: configureErrorSanitizer,\n14: configureSecretGuard,\n15: } from '@utilarium/spotclean';\n16: \n17: // Register OpenAI API key patterns on module load\n18: const redactor = getRedactor();\n19: redactor.register({\n20: name: 'openai',\n21: patterns: [\n22: /sk-[a-zA-Z0-9]{20,}/g,\n23: /sk-proj-[a-zA-Z0-9_-]+/g,\n24: ],\n25: validator: (key: string) => /^sk-(proj-)?[a-zA-Z0-9_-]{20,}$/.test(key),\n26: envVar: 'OPENAI_API_KEY',\n27: description: 'OpenAI API keys',\n28: });\n29: \n30: // Configure spotclean for error sanitization\n31: configureErrorSanitizer({\n32: enabled: true,\n33: environment: process.env.NODE_ENV === 'production' ? 'production' : 'development',\n34: includeCorrelationId: true,\n35: sanitizeStackTraces: process.env.NODE_ENV === 'production',\n36: maxMessageLength: 500,\n37: });\n38: \n39: configureSecretGuard({\n40: enabled: true,\n41: redactionText: '[REDACTED]',\n42: preservePartial: false,\n43: preserveLength: 0,\n44: customPatterns: [\n45: { name: 'openai', pattern: /sk-[a-zA-Z0-9]{20,}/g, description: 'OpenAI API key' },\n46: { name: 'openai-proj', pattern: /sk-proj-[a-zA-Z0-9_-]+/g, description: 'OpenAI project key' },\n47: ],\n48: });\n49: \n50: // ===== INLINE TYPES (from 'execution' package) =====\n51: // These types are duplicated here for build independence.\n52: // When 'execution' is published, these can be imported from there.\n53: \n54: export type Model = string;\n55: \n56: export interface Message {\n57: role: 'user' | 'assistant' | 'system' | 'developer' | 'tool';\n58: content: string | string[] | null;\n59: name?: string;\n60: }\n61: \n62: export interface Request {\n63: messages: Message[];\n64: model: Model;\n65: responseFormat?: any;\n66: validator?: any;\n67: addMessage(message: Message): void;\n68: }\n69: \n70: export interface ProviderResponse {\n71: content: string;\n72: model: string;\n73: usage?: {\n74: inputTokens: number;\n75: outputTokens: number;\n76: };\n77: toolCalls?: Array<{\n78: id: string;\n79: type: 'function';\n80: function: {\n81: name: string;\n82: arguments: string;\n83: };\n84: }>;\n85: }\n86: \n87: export interface ExecutionOptions {\n88: apiKey?: string;\n89: model?: string;\n90: temperature?: number;\n91: maxTokens?: number;\n92: timeout?: number;\n93: retries?: number;\n94: }\n95: \n96: export interface Provider {\n97: readonly name: string;\n98: execute(request: Request, options?: ExecutionOptions): Promise<ProviderResponse>;\n99: supportsModel?(model: Model): boolean;\n100: }\n101: \n102: /**\n103: * OpenAI Provider implementation\n104: */\n105: export class OpenAIProvider implements Provider {\n106: readonly name = 'openai';\n107: \n108: /**\n109: * Check if this provider supports a given model\n110: */\n111: supportsModel(model: Model): boolean {\n112: if (!model) return true; // Default to OpenAI\n113: return (\n114: model.startsWith('gpt') ||\n115: model.startsWith('o1') ||\n116: model.startsWith('o3') ||\n117: model.startsWith('o4')\n118: );\n119: }\n120: \n121: /**\n122: * Execute a request against OpenAI\n123: */\n124: async execute(\n125: request: Request,\n126: options: ExecutionOptions = {}\n127: ): Promise<ProviderResponse> {\n128: const apiKey = options.apiKey || process.env.OPENAI_API_KEY;\n129: \n130: if (!apiKey) {\n131: throw new Error('OpenAI API key is required. Set OPENAI_API_KEY environment variable.');\n132: }\n133: \n134: // Validate key format\n135: const validation = redactor.validateKey(apiKey, 'openai');\n136: if (!validation.valid) {\n137: throw new Error('Invalid OpenAI API key format');\n138: }\n139: \n140: try {\n141: const client = new OpenAI({ apiKey });\n142: \n143: const model = options.model || request.model || 'gpt-4';\n144: \n145: // Convert messages to OpenAI format\n146: const messages = request.messages.map((msg) => {\n147: const role =\n148: msg.role === 'developer' ? 'system' : msg.role;\n149: \n150: return {\n151: role: role,\n152: content:\n153: typeof msg.content === 'string'\n154: ? msg.content\n155: : JSON.stringify(msg.content),\n156: name: msg.name,\n157: } as any;\n158: });\n159: \n160: const response = await client.chat.completions.create({\n161: model: model,\n162: messages: messages,\n163: temperature: options.temperature,\n164: max_tokens: options.maxTokens,\n165: response_format: request.responseFormat,\n166: });\n167: \n168: const choice = response.choices[0];\n169: \n170: return {\n171: content: choice.message.content || '',\n172: model: response.model,\n173: usage: response.usage\n174: ? {\n175: inputTokens: response.usage.prompt_tokens,\n176: outputTokens: response.usage.completion_tokens,\n177: }\n178: : undefined,\n179: toolCalls: choice.message.tool_calls\n180: ?.filter((tc) => tc.type === 'function')\n181: .map((tc) => ({\n182: id: tc.id,\n183: type: 'function' as const,\n184: function: {\n185: name: (tc as any).function.name,\n186: arguments: (tc as any).function.arguments,\n187: },\n188: })),\n189: };\n190: } catch (error) {\n191: // Sanitize error to remove any API keys from error messages\n192: // Use spotclean for comprehensive error sanitization\n193: throw createSafeError(error as Error, { provider: 'openai' });\n194: }\n195: }\n196: }\n197: \n198: /**\n199: * Create a new OpenAI provider instance\n200: */\n201: export function createOpenAIProvider(): OpenAIProvider {\n202: return new OpenAIProvider();\n203: }\n204: \n205: /**\n206: * Package version\n207: */\n208: export const VERSION = '0.0.1';\n209: \n210: export default OpenAIProvider;\n211: ",
195
+ "name": "get_file_content"
196
+ },
197
+ {
198
+ "role": "tool",
199
+ "tool_call_id": "call_RHnlsunxSW2irxkHET6ifYFR",
200
+ "content": "1: import { defineConfig } from \"vite\";\n2: import dts from \"vite-plugin-dts\";\n3: \n4: export default defineConfig({\n5: build: {\n6: lib: {\n7: entry: \"src/index.ts\",\n8: name: \"execution-openai\",\n9: fileName: () => \"index.js\",\n10: formats: [\"es\"],\n11: },\n12: rollupOptions: {\n13: external: [\n14: \"openai\",\n15: \"tiktoken\",\n16: \"execution\",\n17: \"@utilarium/offrecord\",\n18: \"@utilarium/spotclean\",\n19: \"node:crypto\",\n20: ],\n21: },\n22: sourcemap: true,\n23: minify: false,\n24: },\n25: plugins: [dts({ rollupTypes: true })],\n26: });\n27: ",
201
+ "name": "get_file_content"
202
+ },
203
+ {
204
+ "role": "tool",
205
+ "tool_call_id": "call_iVrnJuyXEpyUykRHughtBW1Q",
206
+ "content": "Comparison between v1.0.3 and HEAD:\n\nCommits: 3\n\nFile changes:\n package.json | 6 +++---\n src/index.ts | 4 ++--\n vite.config.ts | 4 ++--\n 3 files changed, 7 insertions(+), 7 deletions(-)\n\n\nCommit summary:\nce6aed9 chore: release 1.0.4\na9e689a feat(openai): inline execution types and harden secret/error sanitization\nd51cb41 chore: bump to 1.0.4-dev.0\n",
207
+ "name": "compare_previous_release"
208
+ },
209
+ {
210
+ "role": "assistant",
211
+ "content": null,
212
+ "tool_calls": [
213
+ {
214
+ "id": "call_ymyzFetkK3Mubx7LC81PryeP",
215
+ "type": "function",
216
+ "function": {
217
+ "name": "search_codebase",
218
+ "arguments": "{\"query\": \"export const VERSION\", \"contextLines\": 2}"
219
+ }
220
+ },
221
+ {
222
+ "id": "call_eMYEl06f9Fi3jGLRWSjiDMuK",
223
+ "type": "function",
224
+ "function": {
225
+ "name": "search_codebase",
226
+ "arguments": "{\"query\": \"from 'execution'\", \"contextLines\": 2}"
227
+ }
228
+ },
229
+ {
230
+ "id": "call_mbVo4VsEEY8VGP7gLCHu99n0",
231
+ "type": "function",
232
+ "function": {
233
+ "name": "get_file_dependencies",
234
+ "arguments": "{\"filePaths\": [\"src/index.ts\", \"vite.config.ts\", \"package.json\"]}"
235
+ }
236
+ },
237
+ {
238
+ "id": "call_1ybFoZQoNWR5JcmrQcxFqC7X",
239
+ "type": "function",
240
+ "function": {
241
+ "name": "get_related_tests",
242
+ "arguments": "{\"filePaths\": [\"src/index.ts\"]}"
243
+ }
244
+ }
245
+ ]
246
+ },
247
+ {
248
+ "role": "tool",
249
+ "tool_call_id": "call_ymyzFetkK3Mubx7LC81PryeP",
250
+ "content": "src/index.ts-206- * Package version\nsrc/index.ts-207- */\nsrc/index.ts:208:export const VERSION = '0.0.1';\nsrc/index.ts-209-\nsrc/index.ts-210-export default OpenAIProvider;\n",
251
+ "name": "search_codebase"
252
+ },
253
+ {
254
+ "role": "tool",
255
+ "tool_call_id": "call_eMYEl06f9Fi3jGLRWSjiDMuK",
256
+ "content": "src/index.ts-48-});\nsrc/index.ts-49-\nsrc/index.ts:50:// ===== INLINE TYPES (from 'execution' package) =====\nsrc/index.ts-51-// These types are duplicated here for build independence.\nsrc/index.ts-52-// When 'execution' is published, these can be imported from there.\n",
257
+ "name": "search_codebase"
258
+ },
259
+ {
260
+ "role": "tool",
261
+ "tool_call_id": "call_mbVo4VsEEY8VGP7gLCHu99n0",
262
+ "content": "Files importing src/index.ts:\ntests/index.test.ts\n",
263
+ "name": "get_file_dependencies"
264
+ },
265
+ {
266
+ "role": "tool",
267
+ "tool_call_id": "call_1ybFoZQoNWR5JcmrQcxFqC7X",
268
+ "content": "Found related test files:\nsrc/index.ts",
269
+ "name": "get_related_tests"
270
+ },
271
+ {
272
+ "role": "assistant",
273
+ "content": null,
274
+ "tool_calls": [
275
+ {
276
+ "id": "call_vW9Lqi8xzeZpZaYjrzyVY9Gy",
277
+ "type": "function",
278
+ "function": {
279
+ "name": "get_file_content",
280
+ "arguments": "{\"filePath\":\"tests/index.test.ts\",\"includeLineNumbers\":true}"
281
+ }
282
+ }
283
+ ]
284
+ },
285
+ {
286
+ "role": "tool",
287
+ "tool_call_id": "call_vW9Lqi8xzeZpZaYjrzyVY9Gy",
288
+ "content": "1: /**\n2: * Tests for execution-openai package\n3: */\n4: \n5: import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';\n6: import {\n7: OpenAIProvider,\n8: createOpenAIProvider,\n9: VERSION,\n10: type Message,\n11: type Request,\n12: type ExecutionOptions,\n13: type ProviderResponse,\n14: type Provider,\n15: } from '../src/index.js';\n16: \n17: describe('OpenAIProvider', () => {\n18: let provider: OpenAIProvider;\n19: \n20: beforeEach(() => {\n21: provider = new OpenAIProvider();\n22: });\n23: \n24: describe('name', () => {\n25: it('should have name \"openai\"', () => {\n26: expect(provider.name).toBe('openai');\n27: });\n28: });\n29: \n30: describe('supportsModel', () => {\n31: it('should support GPT models', () => {\n32: expect(provider.supportsModel('gpt-4')).toBe(true);\n33: expect(provider.supportsModel('gpt-4o')).toBe(true);\n34: expect(provider.supportsModel('gpt-4-turbo')).toBe(true);\n35: expect(provider.supportsModel('gpt-3.5-turbo')).toBe(true);\n36: });\n37: \n38: it('should support O1/O3/O4 models', () => {\n39: expect(provider.supportsModel('o1-preview')).toBe(true);\n40: expect(provider.supportsModel('o1-mini')).toBe(true);\n41: expect(provider.supportsModel('o3-mini')).toBe(true);\n42: expect(provider.supportsModel('o4-mini')).toBe(true);\n43: });\n44: \n45: it('should not support Claude models', () => {\n46: expect(provider.supportsModel('claude-3-opus-20240229')).toBe(false);\n47: expect(provider.supportsModel('claude-3-sonnet-20240229')).toBe(false);\n48: });\n49: \n50: it('should not support Gemini models', () => {\n51: expect(provider.supportsModel('gemini-1.5-pro')).toBe(false);\n52: expect(provider.supportsModel('gemini-1.5-flash')).toBe(false);\n53: });\n54: \n55: it('should return true for empty/undefined model (default to OpenAI)', () => {\n56: expect(provider.supportsModel('')).toBe(true);\n57: });\n58: });\n59: \n60: describe('execute', () => {\n61: const originalEnv = process.env;\n62: \n63: beforeEach(() => {\n64: process.env = { ...originalEnv };\n65: delete process.env.OPENAI_API_KEY;\n66: });\n67: \n68: afterEach(() => {\n69: process.env = originalEnv;\n70: });\n71: \n72: it('should throw error when no API key is provided', async () => {\n73: const request: Request = {\n74: messages: [{ role: 'user', content: 'Hello' }],\n75: model: 'gpt-4',\n76: addMessage: vi.fn(),\n77: };\n78: \n79: await expect(provider.execute(request)).rejects.toThrow(\n80: 'OpenAI API key is required'\n81: );\n82: });\n83: \n84: it('should throw error when API key is empty string', async () => {\n85: const request: Request = {\n86: messages: [{ role: 'user', content: 'Hello' }],\n87: model: 'gpt-4',\n88: addMessage: vi.fn(),\n89: };\n90: \n91: await expect(provider.execute(request, { apiKey: '' })).rejects.toThrow(\n92: 'OpenAI API key is required'\n93: );\n94: });\n95: });\n96: \n97: describe('implements Provider interface', () => {\n98: it('should satisfy Provider interface', () => {\n99: const p: Provider = provider;\n100: expect(p.name).toBe('openai');\n101: expect(typeof p.execute).toBe('function');\n102: expect(typeof p.supportsModel).toBe('function');\n103: });\n104: });\n105: });\n106: \n107: describe('createOpenAIProvider', () => {\n108: it('should create a new OpenAIProvider instance', () => {\n109: const provider = createOpenAIProvider();\n110: expect(provider).toBeInstanceOf(OpenAIProvider);\n111: expect(provider.name).toBe('openai');\n112: });\n113: });\n114: \n115: describe('VERSION', () => {\n116: it('should export version string', () => {\n117: expect(VERSION).toBe('0.0.1');\n118: });\n119: });\n120: \n121: describe('Type exports', () => {\n122: it('should export Message type', () => {\n123: const msg: Message = {\n124: role: 'user',\n125: content: 'Hello',\n126: };\n127: expect(msg.role).toBe('user');\n128: expect(msg.content).toBe('Hello');\n129: });\n130: \n131: it('should support all message roles', () => {\n132: const roles: Message['role'][] = ['user', 'assistant', 'system', 'developer', 'tool'];\n133: roles.forEach(role => {\n134: const msg: Message = { role, content: 'test' };\n135: expect(msg.role).toBe(role);\n136: });\n137: });\n138: \n139: it('should support array content', () => {\n140: const msg: Message = {\n141: role: 'user',\n142: content: ['Hello', 'World'],\n143: };\n144: expect(Array.isArray(msg.content)).toBe(true);\n145: });\n146: \n147: it('should support null content', () => {\n148: const msg: Message = {\n149: role: 'assistant',\n150: content: null,\n151: };\n152: expect(msg.content).toBeNull();\n153: });\n154: \n155: it('should export ExecutionOptions type', () => {\n156: const opts: ExecutionOptions = {\n157: apiKey: 'test-key',\n158: model: 'gpt-4',\n159: temperature: 0.7,\n160: maxTokens: 1000,\n161: timeout: 30000,\n162: retries: 3,\n163: };\n164: expect(opts.apiKey).toBe('test-key');\n165: expect(opts.temperature).toBe(0.7);\n166: });\n167: \n168: it('should export ProviderResponse type', () => {\n169: const response: ProviderResponse = {\n170: content: 'Hello!',\n171: model: 'gpt-4',\n172: usage: {\n173: inputTokens: 10,\n174: outputTokens: 5,\n175: },\n176: };\n177: expect(response.content).toBe('Hello!');\n178: expect(response.usage?.inputTokens).toBe(10);\n179: });\n180: \n181: it('should support toolCalls in ProviderResponse', () => {\n182: const response: ProviderResponse = {\n183: content: '',\n184: model: 'gpt-4',\n185: toolCalls: [\n186: {\n187: id: 'call_123',\n188: type: 'function',\n189: function: {\n190: name: 'get_weather',\n191: arguments: '{\"location\": \"NYC\"}',\n192: },\n193: },\n194: ],\n195: };\n196: expect(response.toolCalls).toHaveLength(1);\n197: expect(response.toolCalls?.[0].function.name).toBe('get_weather');\n198: });\n199: });\n200: \n201: ",
289
+ "name": "get_file_content"
290
+ },
291
+ {
292
+ "role": "assistant",
293
+ "content": "RELEASE_TITLE:\n1.0.4 — Inline execution types + stronger secret/error sanitization\n\nRELEASE_BODY:\n## Summary\nThis release focuses on making `@riotprompt/execution-openai` more self-contained (by inlining the `execution`-package types it needs) and safer to run in production by improving OpenAI API key redaction and error sanitization.\n\n## Changes in 1.0.4\n\n### Type portability / build independence\n- **Inlined the core “execution” types** (`Model`, `Message`, `Request`, `ProviderResponse`, `ExecutionOptions`, `Provider`) directly into `src/index.ts`.\n - Why it matters: consumers can use the exported types without relying on the `execution` package being available/published, reducing coupling and easing builds in environments where that dependency is not present.\n\n### Security: harder-to-leak secrets and cleaner errors\n- **Registered OpenAI API key patterns with `@utilarium/offrecord`** and added validation for key formats (including `sk-proj-...`).\n- **Enabled and configured `@utilarium/spotclean` sanitization**:\n - Sanitizes error messages (and, in production, stack traces) to reduce the chance of leaking secrets.\n - Wraps thrown errors via `createSafeError(...)` so downstream logs/telemetry are less likely to contain API keys.\n\n### Build configuration tweaks\n- Updated `vite.config.ts` Rollup externals to ensure key runtime dependencies are treated as external during bundling (notably `openai`, `tiktoken`, `@utilarium/offrecord`, `@utilarium/spotclean`, and `node:crypto`).\n\n## Impact for users / developers\n- **Safer operational behavior**: if OpenAI errors include sensitive data, the provider now makes a best effort to redact/sanitize before rethrowing.\n- **Easier consumption of types**: TypeScript users can import the provider-facing types directly from this package without waiting on another package publication.\n\n## Breaking changes\n- No breaking changes were detected in the `main..HEAD` range.\n- Note: error messages may appear different due to sanitization/wrapping (this is typically beneficial, but could affect code/tests that assert on exact error strings)."
294
+ }
295
+ ]
296
+ ```
297
+
298
+ </details>
299
+
300
+ ## Generated Release Notes
301
+
302
+ ### Title
303
+ ```
304
+ 1.0.4 — Inline execution types + stronger secret/error sanitization
305
+ ```
306
+
307
+ ### Body
308
+ ```markdown
309
+ ## Summary
310
+ This release focuses on making `@riotprompt/execution-openai` more self-contained (by inlining the `execution`-package types it needs) and safer to run in production by improving OpenAI API key redaction and error sanitization.
311
+
312
+ ## Changes in 1.0.4
313
+
314
+ ### Type portability / build independence
315
+ - **Inlined the core “execution” types** (`Model`, `Message`, `Request`, `ProviderResponse`, `ExecutionOptions`, `Provider`) directly into `src/index.ts`.
316
+ - Why it matters: consumers can use the exported types without relying on the `execution` package being available/published, reducing coupling and easing builds in environments where that dependency is not present.
317
+
318
+ ### Security: harder-to-leak secrets and cleaner errors
319
+ - **Registered OpenAI API key patterns with `@utilarium/offrecord`** and added validation for key formats (including `sk-proj-...`).
320
+ - **Enabled and configured `@utilarium/spotclean` sanitization**:
321
+ - Sanitizes error messages (and, in production, stack traces) to reduce the chance of leaking secrets.
322
+ - Wraps thrown errors via `createSafeError(...)` so downstream logs/telemetry are less likely to contain API keys.
323
+
324
+ ### Build configuration tweaks
325
+ - Updated `vite.config.ts` Rollup externals to ensure key runtime dependencies are treated as external during bundling (notably `openai`, `tiktoken`, `@utilarium/offrecord`, `@utilarium/spotclean`, and `node:crypto`).
326
+
327
+ ## Impact for users / developers
328
+ - **Safer operational behavior**: if OpenAI errors include sensitive data, the provider now makes a best effort to redact/sanitize before rethrowing.
329
+ - **Easier consumption of types**: TypeScript users can import the provider-facing types directly from this package without waiting on another package publication.
330
+
331
+ ## Breaking changes
332
+ - No breaking changes were detected in the `main..HEAD` range.
333
+ - Note: error messages may appear different due to sanitization/wrapping (this is typically beneficial, but could affect code/tests that assert on exact error strings).
334
+ ```
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@kjerneverk/execution-openai",
3
+ "version": "1.0.5-dev.0",
4
+ "description": "OpenAI provider for execution - implements Provider interface",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
14
+ "engines": {
15
+ "node": ">=24.0.0"
16
+ },
17
+ "scripts": {
18
+ "clean": "rm -rf dist",
19
+ "build": "vite build",
20
+ "test": "vitest run --coverage",
21
+ "test:coverage": "vitest run --coverage",
22
+ "lint": "eslint src",
23
+ "precommit": "npm run build && npm run lint && npm run test",
24
+ "prepublishOnly": "npm run clean && npm run build"
25
+ },
26
+ "keywords": [
27
+ "llm",
28
+ "openai",
29
+ "gpt",
30
+ "execution",
31
+ "provider"
32
+ ],
33
+ "author": "Tim O'Brien <tobrien@discursive.com>",
34
+ "license": "Apache-2.0",
35
+ "repository": {
36
+ "type": "git",
37
+ "url": "https://github.com/kjerneverk/execution-openai"
38
+ },
39
+ "dependencies": {
40
+ "@utilarium/offrecord": "^0.0.3",
41
+ "@utilarium/spotclean": "^0.0.4",
42
+ "openai": "^6.16.0",
43
+ "tiktoken": "^1.0.21"
44
+ },
45
+ "devDependencies": {
46
+ "@types/node": "^25.0.6",
47
+ "@typescript-eslint/eslint-plugin": "^8.33.1",
48
+ "@typescript-eslint/parser": "^8.33.1",
49
+ "@vitest/coverage-v8": "^4.0.18",
50
+ "ajv": "^8.17.1",
51
+ "eslint": "^9.28.0",
52
+ "globals": "^17.2.0",
53
+ "typescript": "^5.8.3",
54
+ "vite": "^7.0.4",
55
+ "vite-plugin-dts": "^4.5.4",
56
+ "vitest": "^4.0.18"
57
+ }
58
+ }
package/package.json~ ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "@riotprompt/execution-openai",
3
+ "version": "1.0.0-dev.0",
4
+ "description": "OpenAI provider for execution - implements Provider interface",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
14
+ "engines": {
15
+ "node": ">=24.0.0"
16
+ },
17
+ "scripts": {
18
+ "clean": "rm -rf dist",
19
+ "build": "vite build",
20
+ "test": "vitest run --coverage",
21
+ "test:coverage": "vitest run --coverage",
22
+ "lint": "eslint src",
23
+ "precommit": "npm run build && npm run lint && npm run test",
24
+ "prepublishOnly": "npm run clean && npm run build"
25
+ },
26
+ "keywords": [
27
+ "llm",
28
+ "openai",
29
+ "gpt",
30
+ "execution",
31
+ "provider"
32
+ ],
33
+ "author": "Tim O'Brien <tobrien@discursive.com>",
34
+ "license": "Apache-2.0",
35
+ "repository": {
36
+ "type": "git",
37
+ "url": "https://github.com/kjerneverk/execution-openai"
38
+ },
39
+ "dependencies": {
40
+ "@theunwalked/offrecord": "^0.0.1",
41
+ "@theunwalked/spotclean": "^0.0.3",
42
+ "openai": "^4.103.0",
43
+ "tiktoken": "^1.0.21"
44
+ },
45
+ "devDependencies": {
46
+ "@types/node": "^25.0.6",
47
+ "@typescript-eslint/eslint-plugin": "^8.33.1",
48
+ "@typescript-eslint/parser": "^8.33.1",
49
+ "@vitest/coverage-v8": "^3.2.4",
50
+ "eslint": "^9.28.0",
51
+ "globals": "^16.2.0",
52
+ "typescript": "^5.8.3",
53
+ "vite": "^7.0.4",
54
+ "vite-plugin-dts": "^4.5.4",
55
+ "vitest": "^3.2.4"
56
+ }
57
+ }