Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Changelog

## 6.1.10

### Fixed

- Extended packed-package verification to reject bare side-effect imports of packages that patch Node builtins while continuing to allow dynamic imports.

### Changed

- Updated `@tangle-network/agent-eval` to `0.135.1` for strict rollout-record validation and stable estimated-cost receipt validation.
- Updated the installation example to pin the matching Knowledge and Eval releases.

## 6.1.9

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Supply application callbacks for those decisions, or use `@tangle-network/agent-
## Install

```bash
pnpm add @tangle-network/agent-knowledge @tangle-network/agent-eval@0.134.1
pnpm add @tangle-network/agent-knowledge@6.1.10 @tangle-network/agent-eval@0.135.1
```

Requires Node.js 20.19 or later.
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tangle-network/agent-knowledge",
"version": "6.1.9",
"version": "6.1.10",
"description": "Build, search, evaluate, and improve source-backed knowledge bases.",
"homepage": "https://github.com/tangle-network/agent-knowledge#readme",
"repository": {
Expand Down Expand Up @@ -75,7 +75,7 @@
"verify:official-optimizers": "node scripts/verify-official-optimizers.mjs"
},
"dependencies": {
"@tangle-network/agent-eval": "0.134.2",
"@tangle-network/agent-eval": "0.135.1",
"@tangle-network/agent-interface": "0.36.0",
"proper-lockfile": "4.1.2",
"zod": "^4.4.3"
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 31 additions & 5 deletions scripts/verify-package.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ const agentInterfaceVersion = sourcePackage.dependencies?.['@tangle-network/agen
if (!/^\d+\.\d+\.\d+$/.test(agentInterfaceVersion)) {
throw new Error('@tangle-network/agent-interface must be pinned to one exact version')
}
assertEdgeUnsafeStaticImportMatcher()
const tempRoot = mkdtempSync(join(tmpdir(), 'agent-knowledge-package-'))

try {
Expand Down Expand Up @@ -228,11 +229,9 @@ function assertNoEdgeUnsafeStaticImports(distDir) {
for (const file of javascriptFiles(distDir)) {
const source = readFileSync(file, 'utf8')
for (const specifier of edgeUnsafeStaticImports) {
const quoted = `["']${specifier.replaceAll('/', '\\/')}["']`
// A static ESM import, a re-export, or a CJS require. `import(...)` is
// deliberately excluded: deferring the module scope is the whole fix.
const statik = new RegExp(`(?:from\\s*${quoted}|require\\(\\s*${quoted}\\s*\\))`)
if (statik.test(source)) offenders.push(`${file.slice(distDir.length + 1)} -> ${specifier}`)
if (hasStaticImport(source, specifier)) {
offenders.push(`${file.slice(distDir.length + 1)} -> ${specifier}`)
}
}
}
if (offenders.length > 0) {
Expand All @@ -247,6 +246,33 @@ function assertNoEdgeUnsafeStaticImports(distDir) {
}
}

function hasStaticImport(source, specifier) {
const escaped = specifier.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
const quoted = `["']${escaped}["']`
// Bound imports, bare side-effect imports, re-exports, and CommonJS require.
// Dynamic import() is deliberately excluded because it defers module scope.
return new RegExp(
`(?:\\bfrom\\s*${quoted}|\\bimport\\s*${quoted}|\\brequire\\(\\s*${quoted}\\s*\\))`,
).test(source)
}

function assertEdgeUnsafeStaticImportMatcher() {
const specifier = 'proper-lockfile'
const cases = [
['bound ESM import', `import value from '${specifier}'`, true],
['bare side-effect ESM import', `import '${specifier}'`, true],
['ESM re-export', `export { value } from '${specifier}'`, true],
['CommonJS require', `require('${specifier}')`, true],
['dynamic import', `await import('${specifier}')`, false],
]
for (const [label, source, expected] of cases) {
const actual = hasStaticImport(source, specifier)
if (actual !== expected) {
throw new Error(`edge-unsafe static import matcher failed: ${label}`)
}
}
}

function javascriptFiles(directory) {
const files = []
for (const entry of readdirSync(directory)) {
Expand Down