Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Host-function globals (0.4.3+) break inline TypeScript whose import binding shares a collection's name

オープン
#2,081 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
48/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
javascript, node.js, rust, typescript
領域
backend, devtools

調査の方向性

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.hb as 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 を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

rivet-dev/agentos のほかの issue

rivet-dev/agentos の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。