Agent Skillsiii-hq/iii › iii-state

iii-state

GitHub

提供基于作用域和键的共享KV存储,支持内存、Redis等适配器。通过响应式触发器实现数据变更后的异步副作用处理,避免轮询,适用于函数间状态共享与原子更新。

engine/src/workers/state/skills/SKILL.md iii-hq/iii

Trigger Scenarios

需要多个函数共享状态 数据变更后需触发异步副作用

Install

npx skills add iii-hq/iii --skill iii-state -g -y
More Options

Non-standard path

npx skills add https://github.com/iii-hq/iii/tree/main/engine/src/workers/state/skills -g -y

Use without installing

npx skills use iii-hq/iii@iii-state

指定 Agent (Claude Code)

npx skills add iii-hq/iii --skill iii-state -a claude-code -g -y

安装 repo 全部 skill

npx skills add iii-hq/iii --all -g -y

预览 repo 内 skill

npx skills add iii-hq/iii --list

SKILL.md

Frontmatter
{
    "name": "iii-state",
    "description": "Shared, adapter-backed key\/value store addressed by scope and key, with a reactive `state` trigger so other functions can run on every create, update, or delete without polling."
}

iii-state

The iii-state worker is a server-side key/value store. Values are addressed by a scope (namespace) and a key, shared across every worker connected to the engine, and persisted through a pluggable adapter (kv, redis, or bridge). Callers reach the store through six state::* functions invoked with iii.trigger({ function_id: 'state::...', payload }).

State does not push updates to SDK clients. Reactivity is delivered by a state trigger type that fires state:created, state:updated, or state:deleted after every successful mutation, so downstream functions can react to data changes without polling. The kv adapter (default) supports in_memory or file_based persistence; redis proxies to a Redis backend; bridge forwards operations to a remote iii engine. The function surface is identical across adapters.

When to Use

  • Two or more functions need shared state without standing up a separate database.
  • A counter or per-entity document needs atomic partial updates instead of read-modify-write.
  • A write in one function should trigger side effects elsewhere (cache invalidation, audit logs, notifications, projections).
  • You want a specific scope/key watched and reacted to only when that slot changes.

Boundaries

  • Schema-free by design — every value is opaque JSON. Use configuration when entries need a registered JSON Schema and validation.
  • Reads (state::get, state::list, state::list_groups) never fire triggers; only set/update/delete do.
  • Trigger delivery is asynchronous and does not roll back the write on handler failure; a delete of a missing key still emits state:deleted with a null old value.
  • Stream-shaped, broadcast-to-subscribers data belongs in iii-stream, not here.

Functions

  • state::set — write or replace the value at a scope/key; fires state:created or state:updated.
  • state::get — read one value by scope and key.
  • state::delete — remove a key and fire state:deleted with the prior value.
  • state::update — apply ordered atomic ops (set, merge, increment, decrement, append, remove) to the stored value.
  • state::list — enumerate every value stored in a scope.
  • state::list_groups — enumerate which scopes currently contain data.

Reactive triggers

Bind a state trigger when a function should run automatically after a value changes — without polling state::get. The engine evaluates every registered state trigger after a successful state::set, state::update, or state::delete and invokes matching handlers asynchronously.

Reach for it when:

  • A write in one worker should drive side effects in another (audit logs, cache invalidation, notifications, projections).
  • You want optional gating via condition_function_id so the handler only runs when a predicate on the event is truthy.

If you only need the new value inside the same function that wrote it, use the mutator's returned old_value / new_value instead of binding a trigger.

How to bind

  1. Register a handler: iii.registerFunction('orders::on-status-change', handler).
  2. Register the trigger:
iii.registerTrigger({
  type: 'state',
  function_id: 'orders::on-status-change',
  config: {
    scope: 'orders',  // optional. Omit to match every scope.
    key: 'status',    // optional. Omit to match every key in the scope.
    // condition_function_id is also supported.
  },
})

All config fields are optional; tighter filters reduce how often the handler runs. To watch several specific keys, register one trigger per scope/key pair. Mutations that fire the trigger: state::set, state::update, state::delete.

For the event payload shape, call iii get function info on the trigger type or handler function id.

Version History

  • c6f6fde Current 2026-08-20 17:18

Same Skill Collection

crates/iii-worker/src/sandbox_daemon/skills/SKILL.md
engine/src/workers/bridge_client/skills/SKILL.md
engine/src/workers/configuration/skills/SKILL.md
engine/src/workers/cron/skills/SKILL.md
engine/src/workers/engine_fn/skills/SKILL.md
engine/src/workers/observability/skills/SKILL.md
engine/src/workers/pubsub/skills/SKILL.md
engine/src/workers/queue/skills/SKILL.md
engine/src/workers/rest_api/skills/SKILL.md
engine/src/workers/shell/skills/SKILL.md
engine/src/workers/stream/skills/SKILL.md
engine/src/workers/worker/skills/SKILL.md
skills/iii-architecture-patterns/SKILL.md
skills/iii-core-primitives/SKILL.md
skills/iii-engine-config/SKILL.md
skills/iii-error-handling/SKILL.md
skills/iii-sdk-reference/SKILL.md
skills/presentation/SKILL.md
skills/iii-getting-started/SKILL.md

Metadata

Files
0
Version
c6f6fde
Hash
65f6075d
Indexed
2026-08-20 17:18

Главная - Вики-сайт
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-30 04:19
浙ICP备14020137号-1 $Гость$