Host-function globals (0.4.3+) break inline TypeScript whose import binding shares a collection's name
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 48/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- javascript, node.js, rust, typescript
調査の方向性
Start with crates/native-sidecar/src/host_functions.rs and crates/native-sidecar/src/language_execution.rs, then review #2057 to understand the change to host-function globals. Reproduce using an hb collection and inline TypeScript imports as described in the issue. Done when the colliding import runs or the reserved-name limitation is clearly documented, with the hbSdk workaround as a comparison.
索引モデルが issue の本文から書いたものです。
説明
Written by an AI agent (Claude) on behalf of @jasonkuhrt.
Since 0.4.3 (#2057), inline TypeScript whose import binding has the same name as a host-function global fails before it runs:
import * as hb from 'hb';
// SyntaxError: Identifier 'hb' has already been declared
We register a host-function collection named hb, and install a typed guest package also named hb (/workspace/node_modules/hb), which wraps the collection's generated agentos-hb command. Agents wrote import * as hb from 'hb' against it, and it ran in our VMs on 0.4.1. On 0.4.4 the same program throws. We read 0.4.2's relevant source as matching 0.4.1's, and 0.4.3's as matching 0.4.4's, but didn't run either.
Cause, as we read the source:
- #2057 moved the host-function globals from a prefix inside the caller's script into a separate prelude that runs before every guest Node entrypoint. That prelude defines
globalThis.hbas non-writable and non-configurable (crates/native-sidecar/src/host_functions.rs,host_function_globals_script). - Inline TypeScript then lowers the namespace import to a script-level
const hb = require('hb')(crates/native-sidecar/src/language_execution.rs, the namespace rewrite and lowering). - A script-level lexical declaration of a name that the global object already holds as a non-configurable property is a SyntaxError, per the spec's
HasRestrictedGlobalProperty. So the program fails at declaration time. - With 0.4.1's same-script prefix, the property didn't exist yet when the script's declarations were checked, so the same code ran.
It's the local binding that collides, not the module: import * as hbSdk from 'hb' works. That's our workaround.
But binding a module by its collection's name is natural, and the resulting error points at the user's own import. Possible fixes:
- make the global configurable;
- lower inline namespace imports so they don't become script-level
consts; - or document the reserved names.
Reproduction: register a collection hb with one function, put any module at node_modules/hb, and run inline TypeScript import * as hb from 'hb'; console.log(typeof hb). On 0.4.4 it throws the SyntaxError above; with import * as hbSdk from 'hb' it runs.
- 主要言語
- Rust
- スター
- 4.8k
- フォーク
- 270
- 平均マージ
- 14時間 28分
- マージ済み PR(30日)
- 55
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
rivet-dev/agentos のほかの issue
-
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
rivet-dev/agentos#2087 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 55/100
メンテナーはふだん 1 日以内に返信
-
難易度 3/5 半日 初心者へのやさしさ 32/100
rivet-dev/agentos#2020 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Inline JavaScript resolves dynamic import() from / instead of the working directory対応中かも @mittal-parth が 40 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
rivet-dev/agentos#1973 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
rivet-dev/agentos の issue をすべて見る
似ている issue
-
bug priority: low ui
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
storytold/photocraft#10370 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
area:doc bug in progress needs-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
bherbruck/solvecraft#9634 · コメント 2 件 · リアクション 1 件 ·
-
inflate: total_in uses plain += on c_ulong (32-bit on Windows), panics in debug for streams > 4 GiBオープン
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
trifectatechfoundation/zlib-rs#570 · コメント 1 件 ·
-
bug discord-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
LanternOps/breeze#10755 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
aranya-project/aranya#803 ·