Scan your whole stack
From OX Research Newsroom
Are you using @code-yeongyu/senpi-agent-core?
Find out what’s in your code.
Scan your apps free in minutes (opens in a new tab)Latest version: v2026.11.30-4
@code-yeongyu/senpi-agent-core was last scanned on 30 Nov 2026 at version 2026.11.30-4. Risk score 5 of 100 (low). No malicious behavior was detected.
| Version | Published | Status |
|---|---|---|
| 2026.11.30-4 LATEST | 30 Nov 2026 | 2 rules fired |
| 2026.11.30-3 | 30 Nov 2026 | 2 rules fired |
| 2026.11.30-2 | 30 Nov 2026 | 2 rules fired |
| 2026.11.30 | 30 Nov 2026 | Not shown |
| 2026.11.29-4 | 29 Nov 2026 | Not shown |
Findings for v2026.11.30-4. 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 package points at a source repository whose own package manifest names a different package. Copies of well-known projects do this to borrow their reputation. A rename or a fork can look the same, so treat it as a prompt to check where the package really comes from.
LOWThe score describes 2026.11.30-4; other versions have their own rules, not their own score.
The publisher’s own README, as collected from the registry.
Stateful agent with tool execution and event streaming. Built on @earendil-works/pi-ai.
npm install @earendil-works/pi-agent-core
# Bun alternative
bun add @earendil-works/pi-agent-core
The SQLite session backend and the node:sqlite adapter live in a separate package, @earendil-works/pi-storage-sqlite-node, so the core package does not pull in runtime builtins or native SQLite dependencies by default. The backend accepts a runtime-specific SQLite factory, allowing other session backends to ship as their own packages in the future.
This fork keeps the agent harness (src/harness/**) in this package, together with its subpath exports (./node, ./harness/*, ./experimental/pico3) and the SQLite session backend package. Upstream v1.0.0 moved that runtime into pi-durable; the fork did not adopt that move, so coding-agent keeps importing the harness from @earendil-works/pi-agent-core.
import { Agent } from "@earendil-works/pi-agent-core";
import { createModels } from "@earendil-works/pi-ai";
import { anthropicProvider } from "@earendil-works/pi-ai/providers/anthropic";
const models = createModels();
models.setProvider(anthropicProvider());
const model = models.getModel("anthropic", "claude-sonnet-4-6");
if (!model) throw new Error("Model not found");
const agent = new Agent({
initialState: {
systemPrompt: "You are a helpful assistant.",
model,
},
streamFn: models.streamSimple.bind(models),
});
agent.subscribe((event) => {
if (event.type === "message_update" && event.assistantMessageEvent.type === "text_delta") {
// Stream just the new text chunk
process.stdout.write(event.assistantMessageEvent.delta);
}
});
await agent.prompt("Hello!");
Transport-neutral facet-service primitives live in @earendil-works/chord. The agent core does not export the service runtime.
The agent works with AgentMessage, a flexible type that can include:
user, assistant, toolResult)LLMs only understand user, assistant, and toolResult. The convertToLlm function bridges this gap by filtering and transforming messages before each LLM call.
AgentMessage[] → transformContext() → AgentMessage[] → convertToLlm() → Message[] → LLM
(optional) (required)
The agent emits events for UI updates. Understanding the event sequence helps build responsive interfaces.
When you call prompt("Hello"):
prompt("Hello")
├─ agent_start
├─ turn_start
├─ message_start { message: userMessage } // Your prompt
├─ message_end { message: userMessage }
├─ message_start { message: assistantMessage } // LLM starts responding
├─ message_update { message: partial... } // Streaming chunks
├─ message_update { message: partial... }
├─ message_end { message: assistantMessage } // Complete response
├─ turn_end { message, toolResults: [] }
└─ agent_end { messages: [...] }
If the assistant calls tools, the loop continues:
prompt("Read config.json")
├─ agent_start
├─ turn_start
├─ message_start/end { userMessage }
├─ message_start { assistantMessage with toolCall }
├─ message_update...
├─ message_end { assistantMessage }
├─ tool_execution_start { toolCallId, toolName, args }
├─ tool_execution_update { partialResult } // If tool streams
├─ tool_execution_end { toolCallId, result }
├─ message_start/end { toolResultMessage }
├─ turn_end { message, toolResults: [toolResult] }
│
├─ turn_start // Next turn
├─ message_start { assistantMessage } // LLM responds to tool result
├─ message_update...
├─ message_end
├─ turn_end
└─ agent_end
Tool execution mode is configurable:
parallel (default): preflight tool calls sequentially, execute allowed tools concurrently, emit tool_execution_end as soon as each tool is finalized, then emit toolResult messages and turn_end.toolResults in assistant source ordersequential: execute tool calls one by one, matching the historical behaviorIn parallel mode, tool completion events follow tool completion order, but persisted toolResult messages still follow assistant source order.
The mode can be set globally via toolExecution in the agent config, or per-tool via executionMode on AgentTool. In parallel mode, a tool call targeting a tool with executionMode: "sequential" runs as an exclusive barrier: it waits for all previously scheduled calls in the batch to finish, and later calls wait for it to complete. Parallel tools before or after the barrier still execute concurrently with each other.
The beforeToolCall hook runs after tool_execution_start and validated argument parsing. It can block execution and attach terminate: true to the blocked result. The afterToolCall hook runs after tool execution finishes and before tool_execution_end and final tool result message events are emitted.
Tools, blocked beforeToolCall results, and afterToolCall overrides can return terminate: true to hint that the automatic follow-up LLM call should be skipped. The loop only stops early when every finalized tool result in that batch sets terminate: true. Mixed batches continue normally.
When you use the Agent class, assistant message_end processing is treated as a barrier before tool preflight begins. That means beforeToolCall sees agent state that already includes the assistant message that requested the tool call.
prepareRequest runs immediately before every conversational provider request, including the first. Use it to install canonical persisted context after pending input has been emitted:
agent.prepareRequest = async ({ context }) => ({
context: { ...context, messages: await session.loadModelContext() },
});
prepareRequest does not poll queues. Steering queued while it runs waits for the next normal steering poll.
finishTurn runs after the assistant message and all tool results are finalized, but before turn_end. It runs for normal, error, and aborted responses:
agent.finishTurn = async ({ message }) => {
if (message.stopReason === "error" || message.stopReason === "aborted") return;
if (shouldEndRun(message)) return { action: "end" };
return needsAnotherResponse(message) ? { action: "continue" } : undefined;
};
Returning undefined keeps normal scheduling. { action: "end" } stops right after turn_end, before polling steering or follow-up queues or preparing another request. On a normal response, { action: "continue" } makes sure one more provider request happens: tool results, steering, or a follow-up that already cause that request satisfy it, and otherwise the loop makes one context-only request. Error and aborted responses stay hard exits, so their decisions are ignored. finishTurn runs again after the next request, so returning { action: "continue" } unconditionally loops forever. Low-level loop callers set the same hooks in AgentLoopConfig.
To migrate from the removed shouldStopAfterTurn, return { action: "end" } and guard error and aborted responses to keep the old normal-response-only invocation:
finishTurn: async (turn, signal) => {
if (turn.message.stopReason === "error" || turn.message.stopReason === "aborted") return;
return (await shouldStop(turn, signal)) ? { action: "end" } : undefined;
},
Each provider turn follows this lifecycle:
selected input events
→ prepareRequest
→ provider response
→ tool results
→ finishTurn
→ turn_end
→ existing continuation scheduling or agent_end
agent.peekQueuedMessages() previews the next queue-selected batch, respecting the queue modes, without consuming it.
continue() resumes from existing context without adding a new message. Use it for retries after errors.
// After an error, retry from current state
await agent.continue();
// Keep queued user input out of the retry request and use shorter liveness
// bounds without mutating the Agent's configured defaults.
await agent.continue({
deferQueuedMessages: true,
timeoutMs: 30_000,
streamStartTimeoutMs: 30_000,
});
The last message in context must be user or toolResult (not assistant). Continuation options are
one-shot: queue deferral and both timeout overrides apply only to the first provider request. If that
request succeeds and the same run continues through tools or queued input, later provider requests use
the Agent's configured timeoutMs and streamStartTimeoutMs. continueWithQueuedMessages(options)
keeps compaction recovery queue-first; the selected queued message becomes the continuation input, so
deferQueuedMessages cannot defer that message, while the first-request timeout overrides still apply.
| Event | Description |
|---|---|
agent_start |
Agent begins processing |
agent_end |
Final event for the run. Awaited subscribers for this event still count toward settlement |
turn_start |
New turn begins (one LLM call + tool executions) |
turn_end |
Turn completes with assistant message and tool results |
message_start |
Any message begins (user, assistant, toolResult) |
message_update |
Assistant only. Includes assistantMessageEvent with delta |
message_end |
Message completes |
tool_execution_start |
Tool begins |
tool_execution_update |
Tool streams progress |
tool_execution_end |
Tool completes |
Agent.subscribe() listeners are awaited in registration order. agent_end means no more loop events will be emitted, but await agent.waitForIdle() and await agent.prompt(...) only settle after awaited agent_end listeners finish.
const agent = new Agent({
// Initial state
initialState: {
systemPrompt: string,
model: Model<any>,
thinkingLevel: "off" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max",
tools: AgentTool<any>[],
messages: AgentMessage[],
},
// Convert AgentMessage[] to LLM Message[] (required for custom message types)
convertToLlm: (messages) => messages.filter(...),
// Transform context before convertToLlm (for pruning, compaction)
transformContext: async (messages, signal) => pruneOldMessages(messages),
// Steering mode: "one-at-a-time" (default) or "all"
steeringMode: "one-at-a-time",
// Follow-up mode: "one-at-a-time" (default) or "all"
followUpMode: "one-at-a-time",
// Required stream function
streamFn: models.streamSimple.bind(models),
// Session ID for provider caching
sessionId: "session-123",
// Dynamic API key resolution (for expiring OAuth tokens)
getApiKey: async (provider) => refreshToken(),
// Tool execution mode: "parallel" (default) or "sequential"
toolExecution: "parallel",
// Preflight each tool call after args are validated. Can block execution.
beforeToolCall: async ({ toolCall, args, context }) => {
if (toolCall.name === "bash") {
return { block: true, reason: "bash is disabled", terminate: true };
}
},
// Postprocess each tool result before final tool events are emitted.
afterToolCall: async ({ toolCall, result, isError, context }) => {
if (toolCall.name === "notify_done" && !isError) {
return { terminate: true };
}
if (!isError) {
return { details: { ...result.details, audited: true } };
}
},
// End the run gracefully after a completed turn, before queued messages are polled.
finishTurn: async ({ message, context }, signal) => {
if (message.stopReason === "error" || message.stopReason === "aborted") return;
return (await shouldCompactBeforeNextTurn(context.messages, signal)) ? { action: "end" } : undefined;
},
// Custom thinking budgets for token-based providers
thinkingBudgets: {
minimal: 128,
low: 512,
medium: 1024,
high: 2048,
},
});
interface AgentState {
systemPrompt: string;
model: Model<any>;
thinkingLevel: ThinkingLevel;
tools: AgentTool<any>[];
messages: AgentMessage[];
readonly isStreaming: boolean;
readonly streamingMessage?: AgentMessage;
readonly pendingToolCalls: ReadonlySet<string>;
readonly errorMessage?: string;
}
Access state via agent.state.
Assigning agent.state.tools = [...] or agent.state.messages = [...] copies the top-level array before storing it. Mutating the returned array mutates the current agent state.
During streaming, agent.state.streamingMessage contains the current partial assistant message.
agent.state.isStreaming remains true until the run fully settles, including awaited agent_end subscribers.
// Text prompt
await agent.prompt("Hello");
// With images
await agent.prompt("What's in this image?", [
{ type: "image", data: base64Data, mimeType: "image/jpeg" }
]);
// AgentMessage directly
await agent.prompt({ role: "user", content: "Hello", timestamp: Date.now() });
// Continue from current context (last message must be user or toolResult)
await agent.continue();
agent.state.systemPrompt = "New prompt";
agent.state.model = getModel("openai", "gpt-4o");
agent.state.thinkingLevel = "medium";
agent.state.tools = [myTool];
agent.toolExecution = "sequential";
agent.beforeToolCall = async ({ toolCall }) => undefined;
agent.afterToolCall = async ({ toolCall, result }) => undefined;
agent.prepareRequest = async ({ context }) => undefined;
agent.finishTurn = async () => undefined;
agent.state.messages = newMessages; // top-level array is copied
agent.state.messages.push(message);
agent.reset();
agent.sessionId = "session-123";
agent.thinkingBudgets = {
minimal: 128,
low: 512,
medium: 1024,
high: 2048,
};
agent.abort(); // Cancel current operation
await agent.waitForIdle(); // Wait for completion
const unsubscribe = agent.subscribe(async (event, signal) => {
if (event.type === "agent_end") {
// Final barrier work for the run
await flushSessionState(signal);
}
});
unsubscribe();
Steering messages let you interrupt the agent while tools are running. Follow-up messages let you queue work after the agent would otherwise stop.
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.
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).
The publisher’s own links, as the registry reports them. These are not sources for the assessment on this page.