iii-worker-manager
它能做什么
设置工作进程用来连接 iii 引擎的监听器,并控制每个连接可以使用哪些函数。适合需要向其他工作进程或网络开放 iii 引擎、并且要做访问控制的开发者。
适用场景
- ✓当你希望另一个网络上的工作进程安全地连接你的引擎时。
- ✓当你需要限制已连接的工作进程可以调用哪些函数时。
- ✓当你想记录或限制经过引擎的每一次调用时。
技能链接
https://github.com/iii-hq/iii/blob/main/engine/src/workers/worker/skills/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请帮我把 iii 引擎开放给不可信的网络,并设置访问规则,限制每个已连接的工作进程可以调用的内容。”
每周 5 个新技能,1 分钟读完。
工作原理
该技能会在不同端口上配置 WebSocket 监听器,每个监听器都有自己的访问规则。每个连接都会进行访问检查,还可以使用可选的中间件函数,在调用到达目标之前进行审计、限流或修改。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
iii-worker-manager
The iii-worker-manager is a mandatory engine worker that opens WebSocket listeners. The base
engine.workers.iii-worker-manager entry sets the main port (49134 by default); #instance
entries open separate listeners with their own RBAC, middleware, and registration hooks. Channels
are mounted on every listener at /ws/channels/{channel_id}.
When to Use
- Exposing the engine to an untrusted network — RBAC is mandatory, never open the engine port itself. Use the standalone
rbac-proxyworker (iii trigger compose::add worker=rbac-proxy), which applies these RBAC rules on its own port out of process. A second#instancelistener with anrbacblock and anauth_function_idis the in-engine alternative. - Restricting which functions a connected worker can invoke — combine
expose_functionsfilters (operator-side) withforbidden_functionsfromAuthResult(per-session, hard deny). - Auditing, rate-limiting, or enriching every invocation — set
middleware_function_idon the listener; the middleware decides whether to call the target and what to return. - Per-tenant or per-session namespace isolation — return
function_registration_prefixfrom the auth function so every function/trigger this session registers is transparently prefixed without the worker code knowing. - Gating dynamic registration — wire
on_function_registration_function_id,on_trigger_registration_function_id, oron_trigger_type_registration_function_idto validate or rewrite registrations.
Boundaries
- The infrastructure carve-out (
engine::channels::create,engine::workers::register,engine::log::*,engine::baggage::*) is always allowed on RBAC listeners regardless ofexpose_functions. Adding one of those IDs toforbidden_functionsdenies it but logs a warning — workers may behave unpredictably (broken setup, lost logs, missing context). - The engine port must remain internal. Only
rbac-proxyor an RBAC-protected#instancelistener may face an external network. - The middleware is not a pre-handler — it must invoke the target function itself (typically via
iii.trigger) and return its result. Returning early without invoking simply skips the call. forbidden_functionsfrom the auth result wins over bothallowed_functionsandexpose_functions. There is no way for a session to override an operator's deny list.- Registration hooks return mapped fields or throw to deny. Omitted result fields keep their original values; returning
{}is a no-op (allow as-is). - Triggers and functions registered through an RBAC session are scoped to that session and cleaned up automatically on disconnect.
Configuration
Two listeners — one internal, one external with in-engine RBAC (the rbac-proxy worker accepts the same rbac block through the configuration worker instead):
engine:
workers:
iii-worker-manager:
port: 49134
"iii-worker-manager#rbac":
host: 0.0.0.0
port: 49135
middleware_function_id: my-project::middleware
rbac:
auth_function_id: my-project::auth
on_function_registration_function_id: my-project::on-fn-reg
on_trigger_registration_function_id: my-project::on-trig-reg
on_trigger_type_registration_function_id: my-project::on-trig-type-reg
expose_functions:
- match("api::*")
- match("*::public")
- metadata:
public: true
Auth function
Receives AuthInput { headers, query_params, ip_address }, returns AuthResult. Throw to reject the connection.
import type { AuthInput, AuthResult } from '@iii-dev/helpers/worker-connection-manager'
iii.registerFunction(
'my-project::auth',
async (input: AuthInput): Promise<AuthResult> => {
const token = input.headers?.['authorization']?.replace(/^Bearer\s+/i, '')
if (!token) throw new Error('Missing credentials')
const user = await validateToken(token)
return {
allowed_functions: [],
forbidden_functions: user.role === 'readonly'
? ['api::users::delete', 'api::users::update']
: [],
allowed_trigger_types: user.role === 'admin' ? ['cron', 'webhook'] : undefined,
allow_trigger_type_registration: user.role === 'admin',
function_registration_prefix: `tenant-${user.tenant_id}`,
context: { user_id: user.id, role: user.role, tenant_id: user.tenant_id },
}
},
)
`A
常见问题
我应该把引擎端口直接开放到互联网上吗?
不应该。面对不可信的网络时必须设置访问规则,推荐使用单独的代理工作进程来执行这些规则。
每个客户可以拥有独立的命名空间吗?
可以。认证函数可以为会话注册的每个函数和触发器添加前缀,从而隔离每个租户。
中间件做什么?
它会看到其监听器上的每一次调用,并决定是否继续传递该调用,以及返回什么结果。
详情
作者的原始描述
WebSocket listener that SDK workers connect to. Use to expose the engine to trusted (internal) and untrusted (RBAC-protected) workers, gate function and trigger registration, and audit or transform every invocation through a middleware function. Mounts channel WebSocket endpoints on every listener.
repo: iii-hq/iii
热度
- GitHub 星标
- 19k
- 排名
- #10490
- 许可证
- —
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
iii-sandbox
19k帮你的智能体在临时隔离的虚拟机中安全运行不可信或由 AI 生成的代码,完成后将其丢弃。
configuration
19k让你的智能体设置一个共享的命名配置值注册表,并按模式进行检查,使工作进程可以读取并响应变化。
iii
19k教你的智能体了解 iii 工作进程如何运作,使其可以先检查已有的功能,再构建新的工作进程来添加能力。
iii-observability
19k帮你的智能体使用 OpenTelemetry 为 iii 引擎添加追踪、结构化日志、指标和告警,让你看清系统正在发生什么。