Introducing The Sweep: OX’s New Live Security Research Series
Register Now
Breaking: The 2026 Vulnpocalypse Hits PHP: Four Critical RCEs, but How Dangerous Are They?
Read the Report
Are you exposed? Connect your apps in minutes.
Scan your apps free

@soiljs/agent

Latest version: v0.3.0

Overview

Last scanned
29 Nov 2026
Published
29 Nov 2026
npm package Publisher: yeanzhi
4 Versions

Scan summary

@soiljs/agent was last scanned on 29 Nov 2026 at version 0.3.0. Risk score 0 of 100. No malicious behavior was detected.

  • Releases: 4 versions, all published within 2 days (28 and 29 Nov 2026).
  • Findings: No rules fired in version 0.3.0.

Versions

4 versions published
Versions and the rules that fired in each
VersionPublishedStatus
0.3.0 LATEST 29 Nov 2026 No rules fired
0.2.0 28 Nov 2026 No rules fired
0.1.0 28 Nov 2026 No rules fired
0.0.0-stage 28 Nov 2026 Not shown

No rules fired in 0.3.0

Findings

Findings for v0.3.0. The score is a capped sum of the weights of the rules that fired — not CVSS, not exploitability, and not a probability. It is not comparable across packages with different scan coverage.

The score describes 0.3.0; other versions have their own rules, not their own score.

README

The publisher’s own README, as collected from the registry.

@soiljs/agent

Foundation execution controls

AgentDefinition accepts toolExecution?: "parallel" | "sequential" (default "parallel"), onMaxTokens?: "complete" | "fail" (default "complete"), and limits?: { maxIterations?: number; maxModelCalls?: number; maxToolCalls?: number }. session.send(input, { limits }) overrides individual limits for that Turn. Limits are nonnegative integers. Iterations count committed model batches; model calls count durable request reservations, including compaction calls and retries; tool calls count execution Attempts, including retries and child delegation, excluding reconcile probes and validation failures. Caps apply before dispatch, including inside multi-tool batches. Unexecuted excess calls become skipped.

Sequential execution persists the scheduling policy and prepares one Step at a time in ledger order. Validation/transformation and approval run before dispatch; their validated input is captured once and reused by approval, execution, retries, and reconcile. Validated values must be acyclic JSON (no class instances, undefined properties, or non-finite numbers) so every backend sees the same value. Approval, child waits, and unknown effects block all later Steps. Parallel remains the default and retains independently committed siblings.

Registered tools may declare terminatesTurn?: boolean only in sequential Agents. A successful T4 commit persists full output, model projection, and completion intent while atomically skipping unstarted later siblings. Recovery completes T7 with status: "completed", stopReason: "tool_terminated", and structured output, without another model call or tool execution. Validation failure, execution failure, approval rejection, and unknown outcomes do not terminate. Cancellation committed before T4 wins (external effects remain unknown); termination committed at T4 wins over later cancellation and pending Steering. Earlier child Turns must finish before a terminating sibling can run. A child Agent may itself terminate and return its structured output to its parent.

TurnOutcome and durable Turn state expose stopReason?: StopReason, providerFinishReason?: string, and partial?: boolean. StopReason is "end_turn" | "tool_terminated" | "max_tokens" | "content_filter" | "max_iterations" | "max_model_calls" | "max_tool_calls" | "cancelled" | "error" | "unknown". Provider finish reasons are the normalized model adapter reasons. Length/content-filter responses skip proposed tools; length preserves partial text and either completes or fails according to onMaxTokens.

Tools also accept modelInputSchema?: JsonSchema independently of their execution inputSchema, and toModelResult?(output, ctx): JsonValue | Promise<JsonValue>. The model schema is sent verbatim to the model; the execution validator may be Standard Schema and transform inputs. Full tool output stays in the ledger; the captured modelOutput alone feeds subsequent calls, replay, session history, and compaction views. Projection is captured before T4, including successful reconcile and authorized manual resolution. Child tools support the same hook after mapOutput, captured with child completion. Existing records without a projection keep their original output behavior; arbitrary output.modelOutput properties are never interpreted as a framework contract.

For singleton servers, static model and instructions can be replaced by:

interface TurnResolutionContext {
  readonly turnContext: Readonly<Record<string, unknown>>;
  readonly scope?: ScopeRef;
  readonly services: Readonly<Record<string, unknown>>;
  readonly sessionId: string;
  readonly turnId: string;
  readonly iteration: number;
}
// AgentDefinition fields:
resolveModel?: (ctx: TurnResolutionContext) => BoundModel | Promise<BoundModel>;
resolveInstructions?: (ctx: TurnResolutionContext) => string | Promise<string>;

Resolvers run per iteration (including recovery), without changing the registered definition or retaining per-user bindings in the registry. Store only serializable user lookup identifiers in Turn context; resolve credentials from host services. Keep prompts and model/protocol identity stable within an active tool chain: the existing committed-prefix and continuation checks still apply. Resolver closures and BoundModel credentials are never serialized by Runtime.

HostControlError, toErrorRecord, JsonValue, and StopReason are re-exported from SPI. Throw new HostControlError({ code, message, requestStage, details }) for host admission/budget/job-lease failures. Only reason, nextAttemptAt, and httpStatus scalar details are retained; messages/detail strings are bounded. admission_rejected is never automatically retried. This error is distinct from LeaseLostError, which fences Runtime storage ownership.

把模型推理、业务工具、审批与恢复组织成可追溯的 Agent 执行流程。它是组合 @soiljs/spi 与 @soiljs/models 的 Runtime 层,适合需要多轮工具调用、人工介入和持久进度的 TypeScript 服务;要求 Node.js ≥22.19。

安装与入口

pnpm add @soiljs/agent @soiljs/models
# 需要进程重启后恢复时,再选持久存储
pnpm add @soiljs/storage-local
导出入口 用途
@soiljs/agent 定义函数、Runtime、Session/Turn 句柄、memoryStorage;重导出公共 SPI 契约与错误

所有导出指向构建后的 dist。模型由各协议的 bind() 提供,Runtime 不接收一组混合的厂商请求参数。

最小可运行示例

配置 OPENAI_API_KEY 后,在 ESM TypeScript 中运行下列代码。天气工具返回固定业务数据,模型请求走真实供应商;完整离线版本见 示例 01。

import { defineAgent, defineTool, openRuntime, runAgent } from "@soiljs/agent";
import { openaiResponses } from "@soiljs/models/openai";

const weather = defineTool<Record<string, unknown>, Record<string, unknown>, { city: string }>({
  name: "get_weather",
  version: "1",
  description: "查询城市天气。",
  inputSchema: {
    type: "object",
    properties: { city: { type: "string" } },
    required: ["city"],
  },
  effect: "none",
  async execute({ city }) {
    return { city, temperatureC: 22, condition: "rain" };
  },
});
const assistant = defineAgent({
  id: "weather-assistant",
  version: "1",
  model: openaiResponses.bind({ model: "gpt-5.4", reasoningEffort: "high" }),
  instructions: "使用 get_weather 查询天气,用中文简洁回答。",
  tools: [weather],
});

const quick = await runAgent(assistant, "杭州天气如何?");
if (quick.status === "completed") console.log(quick.outputText);

await using runtime = await openRuntime({ agent: assistant });
const session = await runtime.openSession(assistant);
const turn = await session.send("根据杭州天气安排一日游");
await turn.steer("只安排室内活动", { fallbackToNewTurn: true });
const next = await session.followUp("列出随身物品");
for await (const event of turn.stream()) {
  if (event.type === "text.delta") process.stdout.write(event.delta ?? "");
}
console.log(await turn.wait(), await next.wait());

核心 API 速查

API / 配置 作用与使用要点
defineAgent 注册稳定 id、version、模型、指令与工具;模型可为 BoundModel 或已注册别名
defineTool 声明输入 Schema、版本、execute、副作用、审批与可选 reconcile
openRuntime 管理存储、工具包与连接器生命周期;接收 agent / agents、models、services、storage、authorizeCommand 等
runAgent / runtime.run 单次任务;后者复用当前 Runtime,创建临时 Session
runtime.openSession / getSession / getTurn 创建会话,或在无状态接口里通过持久 ID 重新取得句柄
session.send 默认拒绝同一 Session 的并发活跃输入,抛 SessionBusyError
turn.steer / session.steer 纠偏输入进入持久收件箱,在安全迭代边界消费为 Step;可原子兜底新 Turn
session.followUp 持久 FIFO;只有前序成功完成才自动出队
runtime.commands approve、resolveUnknown、cancel、steer、resume、dispatch(CommandEnvelope)
defineContextStrategy 压缩提交为 compaction Step;通过 ctx.callModel 记录摘要调用用量
defineSubAgentTool 在独立 Session 派发子 Turn,父级等待时释放租约,按策略级联取消
runtime.subscribeRealtime 订阅内存实时事件,返回取消函数;监听器失败与执行隔离

turn.wait() 返回 TurnOutcome,应按 status 分支处理:

状态 含义
completed 成功完成,可读取 outputText
failed / cancelled 执行失败或经授权取消
waiting_approval 等待工具审批
waiting_resolution 外部操作未决,等待对账或人工裁决
waiting_child 等待子 Turn

Outcome 携带待审批、未决步骤、子步骤与 usage: UsageTotals。流在暂停或终止时关闭,支持保留范围内的 fromEventId 重订阅;实时 delta 有界且可丢弃,不写 Outbox。用量仅汇总完整 Attempt,completeCount、incompleteCount 与 hasIncompleteUsage 暴露缺口。

工具与宿主配置

单 Agent 可写 openRuntime({ agent: assistant }),等价于 openRuntime({ agents: [assistant] })。多个 Agent 或同一 Agent 的多个版本使用 agents;agent 与 agents 互斥,类型检查会拒绝同时传入,JavaScript 调用也会在打开存储前报错。两者都不传时仍可在 runtime.openSession(agent) 或 runtime.run(agent, input) 传入定义来注册;启动恢复所需定义应在启动时注册。

ToolEffect 只有 "none" | "external";ApprovalDecision 只有 "none" | "required",也可用函数按输入决定。输入支持 SPI 的 JSON Schema 子集与 Standard Schema v1;后者可做本地转换,但仅凭 v1 结构无法生成详细 JSON Schema,因此模型端看到通用 object,需要详细参数时应直接给 JSON Schema。

在 openRuntime({ models: { lead } }) 注册模型别名后,可用 defineAgent({ model: "lead", ... })。不可序列化客户端放 services,可序列化请求数据放 Session/Turn context。工具包每个 Runtime 打开一次并随 Runtime 关闭。本包不自动读取模型凭证环境变量,连接配置由模型协议处理。

持久执行与关键边界

  • 默认 memoryStorage() 实现九组 SPI 契约,但数据只存在进程内。注入持久 StorageAdapter 才能跨进程恢复;每次重启仍需注册兼容的 Agent/工具版本。默认自动恢复,也可选 recovery: "manual" 后显式恢复。
  • 账本保存 Session → Turn → Step → Attempt,会话通过 ledger.listSessionTurns() 与已提交 Step 重建,与 Outbox 留存无关。等待态释放租约,并行兄弟 Step 独立提交,Attempt 终态历史不可改写。
  • 外部操作中断后诚实保留 unknown。reconcile 可证实 completed、failed 或 not_executed,否则进入 waiting_resolution。没有 exactly-once;取消无法撤销已经发生的远端副作用。
  • toolCallId 只配对模型消息;跨 Attempt 的操作标识是 operationKey,业务去重独立实现。retryPolicy.maxAttempts 含首次执行;无副作用失败归档后可重试,外部副作用重试需对账证据或显式裁决。
  • 模型输出不是授权。应用应提供 authorizeCommand,云端命令必须经过该钩子,连接器开关不能替代授权。
  • 模型 Step 保存 protocolId、modelId 与原始 continuation。默认超过 65,536 UTF-8 字节时先写产物再提交引用,可用 continuationInlineThresholdBytes 调整。活跃工具链的协议/模型或续接状态不匹配时拒绝继续;历史已完成 Turn 可投影为普通对话后更换模型。
  • 压缩之间保持已提交前缀与完整工具配对;view.messagesToCompact 提供不含旧协议状态的对话。子 Agent 的 mapOutput 只投影已提交结果;limits.maxSubTurnDepth 默认 8。

深入阅读与本地校验

在线 API · 生命周期 · 压缩与子 Agent 示例

从仓库根目录运行,包内类型检查前先构建依赖:

pnpm build
pnpm --filter @soiljs/agent typecheck
pnpm --filter @soiljs/agent exec tsup
pnpm exec vitest run packages/agent/src/__tests__
pnpm exec vitest run --maxWorkers=1 packages/storage-local/src/__tests__/crash-recovery.test.ts

离线测试不代表真实供应商覆盖;子进程崩溃由单独的 SIGKILL 测试验证。

OX Radar and Response Center

Find threats in your stack.

OX Radar can check high-priority threats, like critical package CVEs, against your context.

Each incident is marked Detected or Not Detected with a remediation plan and proof all tracked in the Response Center.

Where it’s listed

The probe returned only these fields for this server — auth requirement, protocol and tool list weren’t observed, so they’re not shown (never guessed).

  • npm @soiljs/agent

References

The publisher’s own links, as the registry reports them. These are not sources for the assessment on this page.

Powered by Read the latest findings

Scan your whole stack

Group 1261154050 1
Group 1261154050
 

From OX Research Newsroom

Copy of Template Design OX Blog (2)
Research

NGINX2Root: Five Critical NGINX Flaws Expose Web Servers to Remote Code Execution

Plug and Pray: Your AI Agents Are Taking Orders From Strangers
Research

Plug and Pray: Your AI Agents Are Taking Orders From Strangers

Copy of Template Design OX Blog (1)
Research

Thousands Of GitHub Accounts Hijacked With wfx-loot CI Secret Stealing Malware Via GitHub Actions & npm

Frame 2085668439 (1)
Group 1261154229