packages/agent-sdk/skills/locus-agent-sdk/SKILL.md
@univedge/locus-agent-sdk shared contracts for agent runtime, hooks, plugins, SSE, and context management. Use when importing SDK types, extending hooks/plugins, or working with agent loop, tool execution, SSE streaming, or prompt building.
npx skillsauth add ShenQingchuan/locus-agent locus-agent-sdkInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
The shared SDK package for Locus Agent providing runtime contracts, hook event model, plugin system, SSE protocol, context management, and prompt building utilities.
@univedge/locus-agent-sdk — never re-export from intermediate modulesTModel, TMessage) to stay framework-agnosticHookDecision — use { type: 'noop' } when no action needed| Module | Purpose | Key Exports |
|--------|---------|-------------|
| runtime/ | Agent loop, tool execution, delegation, policy | AgentLoopOptions, AgentLoopCallbacks, ToolExecutor, StreamingToolExecutor, DelegateArgs, classifyTool |
| hooks/ | Lifecycle events & hook bus | HookEventName, HookCategory, HOOK_CATEGORIES, HookBus, HookHandler, HookDecision, payload types |
| plugins/ | Plugin manifest, permissions, scope | PluginManifest, PluginPermissions, PermissionScope, PluginScope, hasPermission |
| context/ | Auto-compaction & tool result caching | shouldCompact, compactToolResults, CompactionStrategy, ResultCacheStorage |
| prompt/ | System prompt assembly | PromptBuilder, PromptSection, createPromptBuilder |
| sse/ | SSE parsing, dispatching, streaming | parseSSELine, serializeSSEEvent, consumeSSEStream, SSEEventHandlers, dispatchSSEEvent |
| types/ | Shared base types | SSEEvent, ToolCall, ToolResult, CoreMessage, RiskLevel, DelegateDelta |
import type { AgentLoopCallbacks, AgentLoopOptions, AgentLoopResult, PendingToolCall, TokenUsage } from '@univedge/locus-agent-sdk'
AgentLoopOptions<TModel, TMessage> — full config for an agent run (model, messages, callbacks, approval mode, tool allowlist)AgentLoopCallbacks — streaming callbacks: onTextDelta, onToolCallStart, onToolCallResult, onReasoningDelta, onToolPendingApproval, onToolOutputDelta, onDelegateDelta, onFinishAgentLoopResult<TMessage> — run result: text, finishReason, usage, iterations, messagesimport type { StreamingToolExecutor, ToolExecutionContext, ToolExecutor, ToolOutputCallbacks } from '@univedge/locus-agent-sdk'
ToolExecutor<TArgs, TResult> — simple async executorStreamingToolExecutor<TArgs, TResult> — with ToolOutputCallbacks for stdout/stderr streamingToolExecutionContext — conversationId, projectKey, workspaceRootimport type { ToolCategory, ToolPolicyConfig } from '@univedge/locus-agent-sdk'
import { classifyTool } from '@univedge/locus-agent-sdk'
const cat = classifyTool('bash', policy) // 'interactive' | 'trusted' | 'serial' | 'normal'
import type { DelegateArgs, DelegateCallbacks, DelegateResult, SubAgentConfig } from '@univedge/locus-agent-sdk'
| Domain | Events | Category |
|--------|--------|----------|
| session | session:start, session:end | observe |
| message | message:user_received | observe |
| context | context:resolve | enrich |
| prompt | prompt:assemble | enrich |
| model | model:before_call (guard), model:after_call (enrich) | mixed |
| tool | tool:before_execute (guard), tool:approval_required (observe), tool:after_execute (enrich) | mixed |
| delegate | delegate:before_run (guard), delegate:after_run (enrich) | mixed |
| artifact | artifact:plan_written, artifact:file_change_detected | observe |
| run | run:finish, run:error | observe |
import type { HookBus, HookDecision, HookHandler } from '@univedge/locus-agent-sdk'
bus.on('tool:before_execute', async (invocation) => {
// invocation.payload is typed per event
return { type: 'noop' }
})
{ type: 'noop' } — no action{ type: 'append_context', items: ContextItem[] } — inject extra context{ type: 'patch_prompt', patches: PromptPatch[] } — modify system prompt sections{ type: 'suggest', suggestions: SuggestionItem[] } — provide suggestions{ type: 'require_confirmation', reason: string } — pause for user approval{ type: 'block', reason: string, code?: string } — block the operation{ type: 'emit_artifact', artifact: PluginArtifact } — output a plugin artifactimport type { PluginManifest } from '@univedge/locus-agent-sdk'
const manifest: PluginManifest = {
id: 'com.example.git-guardian',
name: 'Git Guardian',
version: '1.0.0',
apiVersion: '1',
entry: { runtime: './index.js' },
hooks: [
{ event: 'tool:before_execute', handler: 'onToolBeforeExecute' },
],
permissions: { workspace: ['read'], tools: ['bash'] },
}
import type { PermissionScope, PluginScope } from '@univedge/locus-agent-sdk'
import { hasPermission, PLUGIN_SCOPE_ORDER } from '@univedge/locus-agent-sdk'
// Scopes: 'global' > 'workspace' > 'project' > 'conversation'
// Permission strings: 'workspace.read', 'tools.invoke:bash', 'network.domain:api.example.com', etc.
import { COMPACTION_SYSTEM_PROMPT, DEFAULT_COMPACTION_THRESHOLD, shouldCompact } from '@univedge/locus-agent-sdk'
if (shouldCompact(inputTokens, contextWindow)) {
// trigger compaction via MessageSummarizer
}
import type { ResultCacheStorage, ToolResultCacheOptions } from '@univedge/locus-agent-sdk'
import { compactToolResults } from '@univedge/locus-agent-sdk'
// Implement ResultCacheStorage for your backend (fs, sqlite, etc.)
const entries = compactToolResults(messages, { storage, hotTailCount: 5, minSizeToCache: 500 })
import { createPromptBuilder } from '@univedge/locus-agent-sdk'
const prompt = createPromptBuilder()
.addSection({ id: 'role', content: 'You are a coding assistant.', priority: 0 })
.addSection({ id: 'rules', content: 'Follow best practices.', priority: 10 })
.build()
Plugins can patch sections via patchSection(id, { sectionId, action: 'append' | 'prepend' | 'replace' | 'remove', content }).
import { createSSEEventPayload, serializeSSEEvent } from '@univedge/locus-agent-sdk'
const line = serializeSSEEvent(createSSEEventPayload('text-delta', { textDelta: 'Hello' }))
// => "data: {\"type\":\"text-delta\",\"textDelta\":\"Hello\"}\n\n"
import type { SSEEventHandlers } from '@univedge/locus-agent-sdk'
import { consumeSSEStream } from '@univedge/locus-agent-sdk'
await consumeSSEStream(response.body.getReader(), {
onTextDelta: d => append(d),
onDone: (id, usage) => finish(id),
})
@univedge/locus-agent-sdk, never from an intermediate barrel that re-exports SDK typesai (Vercel AI SDK), drizzle-orm, or any runtime-specific libraryResultCacheStorage, MessageSummarizer; let consumers inject implementationstools
Use when work should span one or more detached tasks but still behave like one job with a single owner context. TaskFlow is the durable flow substrate under authoring layers like Lobster, ACPX, plugins, or plain code. Keep conditional logic in the caller; use TaskFlow for flow identity, child-task linkage, waiting state, revision-checked mutations, and user-facing emergence.
tools
# Lobster Lobster executes multi-step workflows with approval checkpoints. Use it when: - User wants a repeatable automation (triage, monitor, sync) - Actions need human approval before executing (send, post, delete) - Multiple tool calls should run as one deterministic operation ## When to use Lobster | User intent | Use Lobster? | | ------------------------------------------------------ | --------------------------
tools
# Lobster Lobster executes multi-step workflows with approval checkpoints. Use it when: - User wants a repeatable automation (triage, monitor, sync) - Actions need human approval before executing (send, post, delete) - Multiple tool calls should run as one deterministic operation ## When to use Lobster | User intent | Use Lobster? | | ------------------------------------------------------ | --------------------------
tools
A CLI tool for making authenticated requests to the X (Twitter) API. Use this skill when you need to post tweets, reply, quote, search, read posts, manage followers, send DMs, upload media, or interact with any X API v2 endpoint.