-
Notifications
You must be signed in to change notification settings - Fork 7
Devmode: Improved logging output and sourcemap support #321
Changes from all commits
91155b4
b96dcd4
08ab272
cfc4895
0ab622a
acd8961
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -7,6 +7,7 @@ import { createRequire as __agentuity_createRequire } from 'module'; | |||||||||||||||||||||||
| const require = __agentuity_createRequire(import.meta.url); | ||||||||||||||||||||||||
| import { fileURLToPath as __agentuity_fileURLToPath } from 'url'; | ||||||||||||||||||||||||
| import { dirname as __agentuity_dirname } from 'path'; | ||||||||||||||||||||||||
| import { readFileSync as __agentuity_readFileSync, existsSync as __agentuity_existsSync } from 'fs'; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| const __filename = __agentuity_fileURLToPath(import.meta.url); | ||||||||||||||||||||||||
| const __dirname = __agentuity_dirname(__filename); | ||||||||||||||||||||||||
|
|
@@ -45,4 +46,62 @@ globalThis.__require = (id) => { | |||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| throw new Error('Dynamic require of ' + id + ' is not supported'); | ||||||||||||||||||||||||
| };` | ||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||
| ` | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| // NOTE: this shim is only used in bun since node has built-in source map support | ||||||||||||||||||||||||
| var sourceMapShim = ` | ||||||||||||||||||||||||
| (function () { | ||||||||||||||||||||||||
| const { SourceMapConsumer: __agentuity_SourceMapConsumer } = require('source-map-js'); | ||||||||||||||||||||||||
| const { join: __agentuity_join } = require('path'); | ||||||||||||||||||||||||
| const __prepareStackTrace = Error.prepareStackTrace; | ||||||||||||||||||||||||
| const __cachedSourceMap = {}; | ||||||||||||||||||||||||
| function getSourceMap(filename) { | ||||||||||||||||||||||||
| if (filename in __cachedSourceMap) { | ||||||||||||||||||||||||
| return __cachedSourceMap[filename]; | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| if (!__agentuity_existsSync(filename)) { | ||||||||||||||||||||||||
| return null; | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| const sm = new __agentuity_SourceMapConsumer(__agentuity_readFileSync(filename).toString()); | ||||||||||||||||||||||||
| __cachedSourceMap[filename] = sm; | ||||||||||||||||||||||||
| return sm; | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
Comment on lines
+66
to
+69
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
A minimal fix is to await the promise and make -function getSourceMap(filename) {
+async function getSourceMap(filename) {
@@
- const sm = new __agentuity_SourceMapConsumer(
- __agentuity_readFileSync(filename).toString()
- );
+ const sm = await new __agentuity_SourceMapConsumer(
+ __agentuity_readFileSync(filename).toString()
+ );You will then need to:
Without this change, stack-trace rewriting will break on the first error thrown in Bun. 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||
| const frameRegex = /(.+)\((.+):(\d+):(\d+)\)$/; | ||||||||||||||||||||||||
| Error.prepareStackTrace = function (err, stack) { | ||||||||||||||||||||||||
| const _stack = __prepareStackTrace(err, stack); | ||||||||||||||||||||||||
| const tok = _stack.split('\n'); | ||||||||||||||||||||||||
| const lines = []; | ||||||||||||||||||||||||
| for (const t of tok) { | ||||||||||||||||||||||||
| if (t.includes('.agentuity/') && frameRegex.test(t)) { | ||||||||||||||||||||||||
| const parts = frameRegex.exec(t); | ||||||||||||||||||||||||
| if (parts.length === 5) { | ||||||||||||||||||||||||
| const filename = parts[2]; | ||||||||||||||||||||||||
| const sm = getSourceMap(filename+'.map'); | ||||||||||||||||||||||||
| if (sm) { | ||||||||||||||||||||||||
| const lineno = parts[3]; | ||||||||||||||||||||||||
| const colno = parts[4]; | ||||||||||||||||||||||||
| const pos = sm.originalPositionFor({ | ||||||||||||||||||||||||
| line: +lineno, | ||||||||||||||||||||||||
| column: +colno, | ||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||
| if (pos && pos.source) { | ||||||||||||||||||||||||
| const startIndex = filename.indexOf('.agentuity/'); | ||||||||||||||||||||||||
| const offset = filename.includes('../node_modules/') ? 11 : 0; | ||||||||||||||||||||||||
| const basedir = filename.substring(0, startIndex + offset); | ||||||||||||||||||||||||
| const sourceOffset = pos.source.indexOf('src/'); | ||||||||||||||||||||||||
| const source = pos.source.substring(sourceOffset); | ||||||||||||||||||||||||
| const newfile = __agentuity_join(basedir, source); | ||||||||||||||||||||||||
| const newline = parts[1] + '(' + newfile + ':' + pos.line + ':' + pos.column + ')'; | ||||||||||||||||||||||||
| lines.push(newline); | ||||||||||||||||||||||||
| continue; | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| lines.push(t); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| return lines.join('\n'); | ||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||
| })(); | ||||||||||||||||||||||||
| ` | ||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Verify runner label validity for runs-on.
Actionlint flags
blacksmith-4vcpu-ubuntu-2204as unknown. If this is intended to target a custom self-hosted runner, ensure the runner is configured with that label and include theself-hostedscope (e.g.,runs-on: [self-hosted, blacksmith-4vcpu-ubuntu-2204]). Otherwise, switch to an officially supported label such asubuntu-22.04orubuntu-latest.🧰 Tools
🪛 actionlint (1.7.7)
16-16: label "blacksmith-4vcpu-ubuntu-2204" is unknown. available labels are "windows-latest", "windows-latest-8-cores", "windows-2025", "windows-2022", "windows-2019", "ubuntu-latest", "ubuntu-latest-4-cores", "ubuntu-latest-8-cores", "ubuntu-latest-16-cores", "ubuntu-24.04", "ubuntu-24.04-arm", "ubuntu-22.04", "ubuntu-22.04-arm", "ubuntu-20.04", "macos-latest", "macos-latest-xl", "macos-latest-xlarge", "macos-latest-large", "macos-15-xlarge", "macos-15-large", "macos-15", "macos-14-xl", "macos-14-xlarge", "macos-14-large", "macos-14", "macos-13-xl", "macos-13-xlarge", "macos-13-large", "macos-13", "self-hosted", "x64", "arm", "arm64", "linux", "macos", "windows". if it is a custom label for self-hosted runner, set list of labels in actionlint.yaml config file
(runner-label)
🤖 Prompt for AI Agents