@idleware/ringi 0.5.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/target/dts/adapters/fs/index.d.ts +2 -0
- package/target/dts/adapters/fs/lock.d.ts +1 -0
- package/target/dts/adapters/fs/write.d.ts +5 -0
- package/target/dts/adapters/host-posix/group-state.d.ts +7 -0
- package/target/dts/adapters/host-posix/groups.d.ts +1 -0
- package/target/dts/adapters/host-posix/index.d.ts +2 -0
- package/target/dts/adapters/host-posix/launch.d.ts +7 -0
- package/target/dts/adapters/host-posix/probes.d.ts +5 -0
- package/target/dts/adapters/host-posix/stats.d.ts +9 -0
- package/target/dts/adapters/keys-file/index.d.ts +2 -0
- package/target/dts/adapters/state-fs/index.d.ts +5 -0
- package/target/dts/adapters/tool-claude/index.d.ts +2 -0
- package/target/dts/adapters/tool-codex/index.d.ts +2 -0
- package/target/dts/adapters/tool-cursor/index.d.ts +2 -0
- package/target/dts/adapters/tool-traces/index.d.ts +3 -0
- package/target/dts/adapters/transport-git/branches.d.ts +43 -0
- package/target/dts/adapters/transport-git/files.d.ts +2 -0
- package/target/dts/adapters/transport-git/index.d.ts +32 -0
- package/target/dts/adapters/transport-git/marks.d.ts +20 -0
- package/target/dts/adapters/transport-git/remote/admit.d.ts +7 -0
- package/target/dts/adapters/transport-git/remote/alarms.d.ts +3 -0
- package/target/dts/adapters/transport-git/remote/bootstrap.d.ts +7 -0
- package/target/dts/adapters/transport-git/remote/branch-commit.d.ts +3 -0
- package/target/dts/adapters/transport-git/remote/branch-control.d.ts +15 -0
- package/target/dts/adapters/transport-git/remote/branch-scan.d.ts +2 -0
- package/target/dts/adapters/transport-git/remote/branch.d.ts +5 -0
- package/target/dts/adapters/transport-git/remote/cache.d.ts +3 -0
- package/target/dts/adapters/transport-git/remote/commits.d.ts +2 -0
- package/target/dts/adapters/transport-git/remote/forget.d.ts +2 -0
- package/target/dts/adapters/transport-git/remote/git.d.ts +26 -0
- package/target/dts/adapters/transport-git/remote/heartbeat-facts.d.ts +1 -0
- package/target/dts/adapters/transport-git/remote/heartbeat-name.d.ts +6 -0
- package/target/dts/adapters/transport-git/remote/heartbeat-object.d.ts +10 -0
- package/target/dts/adapters/transport-git/remote/heartbeat-push.d.ts +2 -0
- package/target/dts/adapters/transport-git/remote/heartbeat.d.ts +7 -0
- package/target/dts/adapters/transport-git/remote/keys.d.ts +13 -0
- package/target/dts/adapters/transport-git/remote/main.d.ts +11 -0
- package/target/dts/adapters/transport-git/remote/process.d.ts +20 -0
- package/target/dts/adapters/transport-git/remote/push-retry.d.ts +2 -0
- package/target/dts/adapters/transport-git/remote/push-validate.d.ts +2 -0
- package/target/dts/adapters/transport-git/remote/push.d.ts +16 -0
- package/target/dts/adapters/transport-git/remote/roster.d.ts +7 -0
- package/target/dts/adapters/transport-git/remote/signals.d.ts +15 -0
- package/target/dts/adapters/transport-git/remote/signature.d.ts +5 -0
- package/target/dts/adapters/transport-git/remote/sync-heartbeat.d.ts +2 -0
- package/target/dts/adapters/transport-git/remote/sync-rooms.d.ts +6 -0
- package/target/dts/adapters/transport-git/remote/sync-tags.d.ts +8 -0
- package/target/dts/adapters/transport-git/remote/sync.d.ts +2 -0
- package/target/dts/adapters/transport-git/remote/types.d.ts +64 -0
- package/target/dts/adapters/transport-git/remote.d.ts +17 -0
- package/target/dts/adapters/transport-git/repo.d.ts +31 -0
- package/target/dts/adapters/transport-git/run.d.ts +21 -0
- package/target/dts/adapters/transport-git/signing.d.ts +4 -0
- package/target/dts/adapters/transport-git/tags.d.ts +15 -0
- package/target/dts/adapters/transport-git/transport.d.ts +7 -0
- package/target/dts/adapters/transport-kafka/index.d.ts +2 -0
- package/target/dts/adapters/transport-temporal/index.d.ts +2 -0
- package/target/dts/cli.d.ts +2 -1
- package/target/dts/{cli/agent.d.ts → clients/cli/agent/index.d.ts} +3 -3
- package/target/dts/{cli → clients/cli/agent}/session.d.ts +2 -2
- package/target/dts/clients/cli/arg-parse.d.ts +2 -0
- package/target/dts/{cli → clients/cli}/args.d.ts +2 -2
- package/target/dts/clients/cli/commands.d.ts +2 -0
- package/target/dts/clients/cli/context.d.ts +4 -0
- package/target/dts/{cli/index.d.ts → clients/cli/help.d.ts} +1 -3
- package/target/dts/clients/cli/index.d.ts +4 -0
- package/target/dts/clients/cli/operator/heartbeat-format.d.ts +5 -0
- package/target/dts/clients/cli/operator/heartbeat.d.ts +3 -0
- package/target/dts/clients/cli/operator/hub-commands.d.ts +6 -0
- package/target/dts/clients/cli/operator/hub.d.ts +2 -0
- package/target/dts/clients/cli/operator/index.d.ts +5 -0
- package/target/dts/clients/cli/operator/room-lifecycle.d.ts +5 -0
- package/target/dts/clients/cli/operator/room-list.d.ts +5 -0
- package/target/dts/clients/cli/operator/room-members.d.ts +4 -0
- package/target/dts/clients/cli/operator/room.d.ts +2 -0
- package/target/dts/clients/cli/operator/sessions.d.ts +5 -0
- package/target/dts/clients/cli/operator/watch.d.ts +2 -0
- package/target/dts/clients/cli/operator/where-format.d.ts +7 -0
- package/target/dts/clients/cli/operator/where.d.ts +2 -0
- package/target/dts/clients/cli/shared/budget.d.ts +7 -0
- package/target/dts/clients/cli/shared/files.d.ts +4 -0
- package/target/dts/clients/cli/shared/index.d.ts +7 -0
- package/target/dts/clients/cli/shared/messages.d.ts +7 -0
- package/target/dts/clients/cli/shared/profile.d.ts +4 -0
- package/target/dts/clients/cli/shared/session.d.ts +6 -0
- package/target/dts/clients/cli/shared/signals.d.ts +3 -0
- package/target/dts/clients/cli/shared/work.d.ts +6 -0
- package/target/dts/clients/cli/skill/index.d.ts +3 -0
- package/target/dts/{cli/skill.d.ts → clients/cli/skill/targets.d.ts} +1 -2
- package/target/dts/composition/index.d.ts +2 -0
- package/target/dts/{heartbeat → core/agents/heartbeat}/index.d.ts +2 -4
- package/target/dts/{app/heartbeat.d.ts → core/agents/heartbeat/pulse.d.ts} +5 -6
- package/target/dts/core/agents/heartbeat/singleton.d.ts +3 -0
- package/target/dts/core/agents/heartbeat/tools.d.ts +6 -0
- package/target/dts/{app → core/agents}/overview.d.ts +12 -6
- package/target/dts/core/agents/ports/host.d.ts +47 -0
- package/target/dts/core/agents/ports/index.d.ts +9 -0
- package/target/dts/core/agents/ports/tools.d.ts +18 -0
- package/target/dts/core/agents/sessions/agent.d.ts +70 -0
- package/target/dts/core/agents/sessions/binding.d.ts +9 -0
- package/target/dts/core/agents/sessions/context.d.ts +8 -0
- package/target/dts/{runtime/session.d.ts → core/agents/sessions/index.d.ts} +2 -9
- package/target/dts/core/agents/sessions/join.d.ts +20 -0
- package/target/dts/core/agents/sessions/resume.d.ts +2 -0
- package/target/dts/core/agents/sessions/session.d.ts +46 -0
- package/target/dts/core/agents/sessions/wait.d.ts +38 -0
- package/target/dts/core/agents/turns/budgets.d.ts +5 -0
- package/target/dts/core/agents/turns/dispatch.d.ts +9 -0
- package/target/dts/core/agents/turns/exhaustion.d.ts +11 -0
- package/target/dts/core/agents/turns/grants.d.ts +4 -0
- package/target/dts/core/agents/turns/index.d.ts +4 -0
- package/target/dts/core/agents/turns/limits.d.ts +2 -0
- package/target/dts/core/agents/turns/messages.d.ts +10 -0
- package/target/dts/core/agents/turns/pings.d.ts +5 -0
- package/target/dts/core/agents/turns/plan.d.ts +3 -0
- package/target/dts/core/agents/turns/poll.d.ts +8 -0
- package/target/dts/core/agents/turns/results.d.ts +3 -0
- package/target/dts/core/agents/turns/seat.d.ts +2 -0
- package/target/dts/core/agents/turns/types.d.ts +59 -0
- package/target/dts/core/hub/decisions/budget.d.ts +15 -0
- package/target/dts/core/hub/decisions/check.d.ts +6 -0
- package/target/dts/core/hub/decisions/index.d.ts +5 -0
- package/target/dts/core/hub/decisions/proposal.d.ts +38 -0
- package/target/dts/core/hub/decisions/usage.d.ts +12 -0
- package/target/dts/{runtime/reader.d.ts → core/hub/history/index.d.ts} +12 -6
- package/target/dts/core/hub/ports/index.d.ts +16 -0
- package/target/dts/core/hub/ports/state.d.ts +12 -0
- package/target/dts/{store/index.d.ts → core/hub/ports/store.d.ts} +48 -18
- package/target/dts/core/hub/protocol/index.d.ts +5 -0
- package/target/dts/{protocol/index.d.ts → core/hub/protocol/model.d.ts} +0 -25
- package/target/dts/core/hub/protocol/order.d.ts +2 -0
- package/target/dts/core/hub/protocol/reading.d.ts +8 -0
- package/target/dts/core/hub/protocol/text.d.ts +11 -0
- package/target/dts/core/hub/protocol/threads.d.ts +5 -0
- package/target/dts/core/hub/rooms/compat.d.ts +5 -0
- package/target/dts/core/hub/rooms/hubs.d.ts +14 -0
- package/target/dts/core/hub/rooms/index.d.ts +53 -0
- package/target/dts/core/hub/rooms/messages.d.ts +8 -0
- package/target/dts/core/hub/rooms/rooms.d.ts +10 -0
- package/target/dts/core/hub/signals/check.d.ts +3 -0
- package/target/dts/core/hub/signals/effective.d.ts +3 -0
- package/target/dts/core/hub/signals/index.d.ts +5 -0
- package/target/dts/core/hub/signals/marks.d.ts +4 -0
- package/target/dts/core/hub/signals/model.d.ts +28 -0
- package/target/dts/core/hub/signals/pins.d.ts +5 -0
- package/target/dts/{hub/signals.d.ts → core/hub/signals/write.d.ts} +1 -1
- package/target/dts/core/hub/usecases/actor.d.ts +6 -0
- package/target/dts/{app → core/hub/usecases}/budget.d.ts +5 -18
- package/target/dts/core/hub/usecases/config.d.ts +6 -0
- package/target/dts/{app → core/hub/usecases}/context.d.ts +3 -8
- package/target/dts/{app → core/hub/usecases}/hubs.d.ts +1 -1
- package/target/dts/core/hub/usecases/propose.d.ts +17 -0
- package/target/dts/{app → core/hub/usecases}/room.d.ts +8 -34
- package/target/dts/{app → core/hub/usecases}/rooms.d.ts +2 -6
- package/target/dts/core/hub/usecases/roster.d.ts +5 -0
- package/target/dts/core/hub/usecases/send.d.ts +21 -0
- package/target/dts/core/hub/usecases/staging.d.ts +8 -0
- package/target/dts/{app → core/hub/usecases}/view.d.ts +4 -4
- package/target/dts/{domain/profiles.d.ts → core/hub/work/index.d.ts} +3 -7
- package/target/dts/core/hub/work/parse.d.ts +2 -0
- package/target/dts/core/hub/work/task.d.ts +6 -0
- package/target/dts/core/signing/index.d.ts +35 -0
- package/target/dts/index.d.ts +8 -8
- package/target/dts/lib/fail.d.ts +8 -0
- package/target/dts/lib/index.d.ts +3 -11
- package/target/dts/lib/json.d.ts +1 -0
- package/target/esm/adapters/fs/index.js +5 -0
- package/target/esm/adapters/fs/lock.js +83 -0
- package/target/esm/adapters/fs/write.js +25 -0
- package/target/esm/adapters/host-posix/group-state.js +24 -0
- package/target/esm/adapters/host-posix/groups.js +43 -0
- package/target/esm/adapters/host-posix/index.js +35 -0
- package/target/esm/adapters/host-posix/launch.js +80 -0
- package/target/esm/adapters/host-posix/probes.js +66 -0
- package/target/esm/adapters/host-posix/stats.js +27 -0
- package/target/esm/adapters/keys-file/index.js +68 -0
- package/target/esm/adapters/state-fs/index.js +79 -0
- package/target/esm/adapters/tool-claude/index.js +32 -0
- package/target/esm/adapters/tool-codex/index.js +38 -0
- package/target/esm/adapters/tool-cursor/index.js +8 -0
- package/target/esm/adapters/tool-traces/index.js +18 -0
- package/target/esm/adapters/transport-git/branches.js +155 -0
- package/target/esm/adapters/transport-git/files.js +48 -0
- package/target/esm/adapters/transport-git/index.js +128 -0
- package/target/esm/adapters/transport-git/marks.js +88 -0
- package/target/esm/adapters/transport-git/remote/admit.js +71 -0
- package/target/esm/adapters/transport-git/remote/alarms.js +30 -0
- package/target/esm/adapters/transport-git/remote/bootstrap.js +47 -0
- package/target/esm/adapters/transport-git/remote/branch-commit.js +36 -0
- package/target/esm/adapters/transport-git/remote/branch-control.js +37 -0
- package/target/esm/adapters/transport-git/remote/branch-scan.js +28 -0
- package/target/esm/adapters/transport-git/remote/branch.js +37 -0
- package/target/esm/adapters/transport-git/remote/cache.js +23 -0
- package/target/esm/adapters/transport-git/remote/commits.js +25 -0
- package/target/esm/adapters/transport-git/remote/forget.js +35 -0
- package/target/esm/adapters/transport-git/remote/git.js +58 -0
- package/target/esm/adapters/transport-git/remote/heartbeat-facts.js +35 -0
- package/target/esm/adapters/transport-git/remote/heartbeat-name.js +19 -0
- package/target/esm/adapters/transport-git/remote/heartbeat-object.js +40 -0
- package/target/esm/adapters/transport-git/remote/heartbeat-push.js +44 -0
- package/target/esm/adapters/transport-git/remote/heartbeat.js +44 -0
- package/target/esm/adapters/transport-git/remote/keys.js +75 -0
- package/target/esm/adapters/transport-git/remote/main.js +41 -0
- package/target/esm/adapters/transport-git/remote/process.js +37 -0
- package/target/esm/adapters/transport-git/remote/push-retry.js +46 -0
- package/target/esm/adapters/transport-git/remote/push-validate.js +39 -0
- package/target/esm/adapters/transport-git/remote/push.js +62 -0
- package/target/esm/adapters/transport-git/remote/roster.js +48 -0
- package/target/esm/adapters/transport-git/remote/signals.js +63 -0
- package/target/esm/adapters/transport-git/remote/signature.js +56 -0
- package/target/esm/adapters/transport-git/remote/sync-heartbeat.js +26 -0
- package/target/esm/adapters/transport-git/remote/sync-rooms.js +38 -0
- package/target/esm/adapters/transport-git/remote/sync-tags.js +48 -0
- package/target/esm/adapters/transport-git/remote/sync.js +38 -0
- package/target/esm/adapters/transport-git/remote/types.js +10 -0
- package/target/esm/adapters/transport-git/remote.js +17 -0
- package/target/esm/adapters/transport-git/repo.js +115 -0
- package/target/esm/adapters/transport-git/run.js +57 -0
- package/target/esm/adapters/transport-git/signing.js +44 -0
- package/target/esm/adapters/transport-git/tags.js +21 -0
- package/target/esm/adapters/transport-git/transport.js +29 -0
- package/target/esm/adapters/transport-kafka/index.js +4 -0
- package/target/esm/adapters/transport-temporal/index.js +4 -0
- package/target/esm/cli.js +5 -4
- package/target/esm/{cli/agent.js → clients/cli/agent/index.js} +8 -7
- package/target/esm/{cli → clients/cli/agent}/session.js +7 -7
- package/target/esm/clients/cli/arg-parse.js +41 -0
- package/target/esm/{cli → clients/cli}/args.js +3 -36
- package/target/esm/clients/cli/commands.js +45 -0
- package/target/esm/clients/cli/context.js +6 -0
- package/target/esm/{cli/index.js → clients/cli/help.js} +4 -77
- package/target/esm/clients/cli/index.js +27 -0
- package/target/esm/clients/cli/operator/heartbeat-format.js +8 -0
- package/target/esm/clients/cli/operator/heartbeat.js +35 -0
- package/target/esm/clients/cli/operator/hub-commands.js +37 -0
- package/target/esm/clients/cli/operator/hub.js +10 -0
- package/target/esm/clients/cli/operator/index.js +8 -0
- package/target/esm/clients/cli/operator/room-lifecycle.js +23 -0
- package/target/esm/clients/cli/operator/room-list.js +27 -0
- package/target/esm/clients/cli/operator/room-members.js +15 -0
- package/target/esm/clients/cli/operator/room.js +15 -0
- package/target/esm/clients/cli/operator/sessions.js +32 -0
- package/target/esm/clients/cli/operator/watch.js +15 -0
- package/target/esm/clients/cli/operator/where-format.js +24 -0
- package/target/esm/clients/cli/operator/where.js +32 -0
- package/target/esm/clients/cli/shared/budget.js +50 -0
- package/target/esm/clients/cli/shared/files.js +26 -0
- package/target/esm/clients/cli/shared/index.js +10 -0
- package/target/esm/clients/cli/shared/messages.js +41 -0
- package/target/esm/clients/cli/shared/profile.js +17 -0
- package/target/esm/clients/cli/shared/session.js +8 -0
- package/target/esm/clients/cli/shared/signals.js +21 -0
- package/target/esm/clients/cli/shared/work.js +26 -0
- package/target/esm/clients/cli/skill/index.js +40 -0
- package/target/esm/clients/cli/skill/targets.js +20 -0
- package/target/esm/composition/index.js +34 -0
- package/target/esm/{heartbeat → core/agents/heartbeat}/index.js +14 -12
- package/target/esm/{app/heartbeat.js → core/agents/heartbeat/pulse.js} +31 -55
- package/target/esm/core/agents/heartbeat/singleton.js +38 -0
- package/target/esm/core/agents/heartbeat/tools.js +24 -0
- package/target/esm/{app → core/agents}/overview.js +15 -9
- package/target/esm/core/agents/ports/host.js +4 -0
- package/target/esm/core/agents/ports/index.js +7 -0
- package/target/esm/core/agents/ports/tools.js +5 -0
- package/target/esm/{app → core/agents/sessions}/agent.js +11 -43
- package/target/esm/core/agents/sessions/binding.js +43 -0
- package/target/esm/core/agents/sessions/context.js +11 -0
- package/target/esm/core/agents/sessions/index.js +59 -0
- package/target/esm/core/agents/sessions/join.js +55 -0
- package/target/esm/core/agents/sessions/resume.js +54 -0
- package/target/esm/core/agents/sessions/session.js +28 -0
- package/target/esm/core/agents/sessions/wait.js +47 -0
- package/target/esm/core/agents/turns/budgets.js +48 -0
- package/target/esm/core/agents/turns/dispatch.js +40 -0
- package/target/esm/core/agents/turns/exhaustion.js +16 -0
- package/target/esm/core/agents/turns/grants.js +36 -0
- package/target/esm/core/agents/turns/index.js +33 -0
- package/target/esm/core/agents/turns/limits.js +11 -0
- package/target/esm/core/agents/turns/messages.js +32 -0
- package/target/esm/core/agents/turns/pings.js +30 -0
- package/target/esm/core/agents/turns/plan.js +29 -0
- package/target/esm/core/agents/turns/poll.js +48 -0
- package/target/esm/core/agents/turns/results.js +40 -0
- package/target/esm/core/agents/turns/seat.js +44 -0
- package/target/esm/core/agents/turns/types.js +3 -0
- package/target/esm/{domain/index.js → core/hub/capabilities.js} +3 -3
- package/target/esm/core/hub/decisions/budget.js +40 -0
- package/target/esm/core/hub/decisions/check.js +43 -0
- package/target/esm/core/hub/decisions/index.js +10 -0
- package/target/esm/core/hub/decisions/proposal.js +73 -0
- package/target/esm/core/hub/decisions/usage.js +39 -0
- package/target/esm/core/hub/history/index.js +90 -0
- package/target/esm/core/hub/ports/index.js +10 -0
- package/target/esm/core/hub/ports/state.js +5 -0
- package/target/esm/core/hub/ports/store.js +10 -0
- package/target/esm/{protocol → core/hub/protocol}/files.js +4 -2
- package/target/esm/core/hub/protocol/index.js +9 -0
- package/target/esm/core/hub/protocol/model.js +15 -0
- package/target/esm/core/hub/protocol/order.js +39 -0
- package/target/esm/core/hub/protocol/reading.js +29 -0
- package/target/esm/core/hub/protocol/text.js +95 -0
- package/target/esm/core/hub/protocol/threads.js +52 -0
- package/target/esm/core/hub/rooms/compat.js +51 -0
- package/target/esm/core/hub/rooms/hubs.js +92 -0
- package/target/esm/core/hub/rooms/index.js +23 -0
- package/target/esm/core/hub/rooms/messages.js +47 -0
- package/target/esm/core/hub/rooms/rooms.js +84 -0
- package/target/esm/core/hub/signals/check.js +33 -0
- package/target/esm/core/hub/signals/effective.js +31 -0
- package/target/esm/core/hub/signals/index.js +23 -0
- package/target/esm/core/hub/signals/marks.js +30 -0
- package/target/esm/core/hub/signals/model.js +5 -0
- package/target/esm/core/hub/signals/pins.js +21 -0
- package/target/esm/{hub/signals.js → core/hub/signals/write.js} +4 -4
- package/target/esm/core/hub/usecases/actor.js +3 -0
- package/target/esm/core/hub/usecases/budget.js +78 -0
- package/target/esm/core/hub/usecases/config.js +5 -0
- package/target/esm/core/hub/usecases/context.js +13 -0
- package/target/esm/core/hub/usecases/hubs.js +95 -0
- package/target/esm/core/hub/usecases/propose.js +39 -0
- package/target/esm/core/hub/usecases/room.js +82 -0
- package/target/esm/{app → core/hub/usecases}/rooms.js +11 -63
- package/target/esm/core/hub/usecases/roster.js +47 -0
- package/target/esm/core/hub/usecases/send.js +78 -0
- package/target/esm/core/hub/usecases/staging.js +60 -0
- package/target/esm/{app → core/hub/usecases}/view.js +33 -33
- package/target/esm/core/hub/work/index.js +13 -0
- package/target/esm/core/hub/work/parse.js +37 -0
- package/target/esm/core/hub/work/task.js +68 -0
- package/target/esm/core/signing/index.js +4 -0
- package/target/esm/index.js +7 -6
- package/target/esm/lib/fail.js +18 -0
- package/target/esm/lib/index.js +20 -195
- package/target/esm/lib/json.js +81 -0
- package/target/dts/app/agent.d.ts +0 -109
- package/target/dts/app/session.d.ts +0 -65
- package/target/dts/cli/context.d.ts +0 -6
- package/target/dts/cli/operator.d.ts +0 -10
- package/target/dts/cli/shared.d.ts +0 -27
- package/target/dts/domain/decisions.d.ts +0 -65
- package/target/dts/domain/signals.d.ts +0 -37
- package/target/dts/heartbeat/platform.d.ts +0 -15
- package/target/dts/heartbeat/tools.d.ts +0 -11
- package/target/dts/home/index.d.ts +0 -21
- package/target/dts/hub/index.d.ts +0 -72
- package/target/dts/runtime/watch.d.ts +0 -17
- package/target/dts/store/git/index.d.ts +0 -92
- package/target/dts/store/git/remote.d.ts +0 -95
- package/target/dts/store/kafka/index.d.ts +0 -2
- package/target/dts/store/temporal/index.d.ts +0 -2
- package/target/esm/app/budget.js +0 -95
- package/target/esm/app/context.js +0 -16
- package/target/esm/app/hubs.js +0 -76
- package/target/esm/app/room.js +0 -181
- package/target/esm/app/session.js +0 -99
- package/target/esm/cli/context.js +0 -8
- package/target/esm/cli/operator.js +0 -185
- package/target/esm/cli/shared.js +0 -159
- package/target/esm/cli/skill.js +0 -54
- package/target/esm/domain/decisions.js +0 -178
- package/target/esm/domain/profiles.js +0 -96
- package/target/esm/domain/signals.js +0 -134
- package/target/esm/heartbeat/platform.js +0 -83
- package/target/esm/heartbeat/tools.js +0 -68
- package/target/esm/home/index.js +0 -88
- package/target/esm/hub/index.js +0 -224
- package/target/esm/protocol/index.js +0 -219
- package/target/esm/runtime/reader.js +0 -65
- package/target/esm/runtime/session.js +0 -116
- package/target/esm/runtime/watch.js +0 -321
- package/target/esm/store/git/index.js +0 -719
- package/target/esm/store/git/remote.js +0 -928
- package/target/esm/store/index.js +0 -15
- package/target/esm/store/kafka/index.js +0 -3
- package/target/esm/store/temporal/index.js +0 -3
- /package/target/dts/{domain/index.d.ts → core/hub/capabilities.d.ts} +0 -0
- /package/target/dts/{protocol → core/hub/protocol}/files.d.ts +0 -0
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
// protocol: the message protocol, docs/spec/core-1.md (§3, §5–§7), independent of storage and of any task model. A store
|
|
2
|
-
// turns its records into messages and hands them here: text, threads, inboxes and waking live in this file. What a
|
|
3
|
-
// task is, which states it has and who may move it, is a profile (profile.ts), not part of the protocol.
|
|
4
|
-
import { CC_RE } from './files.js';
|
|
5
|
-
import { fail } from '../lib/index.js';
|
|
6
|
-
export const ID_RE = /^(?=.{1,64}$)[a-z0-9]+(?:[._-][a-z0-9]+)*(?<!\.lock)$/;
|
|
7
|
-
// An agent's id has no dot: it starts the name of its signals, `<agent>.<signal>.<message12>`.
|
|
8
|
-
export const AGENT_RE = /^(?=.{1,64}$)[a-z0-9]+(?:[_-][a-z0-9]+)*$/;
|
|
9
|
-
export const TOKEN_RE = /^[a-z][a-z0-9-]*$/;
|
|
10
|
-
export const HOP_RE = /^(?:0|[1-9]\d{0,5})$/;
|
|
11
|
-
export const TRAILER_RE = /^([A-Za-z][A-Za-z0-9-]*):[ \t]*(.*)$/;
|
|
12
|
-
export const TEXT_MAX = 64 * 1024;
|
|
13
|
-
// Trailers the protocol itself interprets; any other trailer belongs to an extension or a profile.
|
|
14
|
-
export const KNOWN = new Set(['to', 're', 'kind', 'state', 'hop', 'assign', 'roles']);
|
|
15
|
-
export const HEARTBEATS = new Set(['ping', 'pong']);
|
|
16
|
-
// Kinds that are bookkeeping, never delivered to an inbox: heartbeats, usage receipts, cards, room records.
|
|
17
|
-
export const HIDDEN = new Set(['ping', 'pong', 'usage', 'card', 'room']);
|
|
18
|
-
export const one = (m, k) => m.trailers[k]?.[0] ?? null;
|
|
19
|
-
// --- text (§3) ---
|
|
20
|
-
const utf8 = new TextDecoder('utf-8', { fatal: true });
|
|
21
|
-
// Invalid text is dangerous bytes: readers treat the message as absent.
|
|
22
|
-
export const decodeText = (buf) => {
|
|
23
|
-
let s;
|
|
24
|
-
try {
|
|
25
|
-
s = utf8.decode(buf);
|
|
26
|
-
}
|
|
27
|
-
catch {
|
|
28
|
-
return { invalid: 'not valid UTF-8' };
|
|
29
|
-
}
|
|
30
|
-
s = s.replace(/\r\n/g, '\n');
|
|
31
|
-
if (/\r/.test(s))
|
|
32
|
-
return { invalid: 'a CR not followed by LF' };
|
|
33
|
-
if (CC_RE.test(s))
|
|
34
|
-
return { invalid: 'control characters in the text' };
|
|
35
|
-
return { text: s };
|
|
36
|
-
};
|
|
37
|
-
// Parses well-formed and malformed text alike; `bad` names why a message routes nowhere. `isRef` is the store's
|
|
38
|
-
// grammar for message ids in `Re`.
|
|
39
|
-
export const parse = (raw, isRef) => {
|
|
40
|
-
const text = raw.replace(/\r\n/g, '\n').trimEnd();
|
|
41
|
-
const cut = text.lastIndexOf('\n\n');
|
|
42
|
-
const tail = cut < 0 ? [] : text.slice(cut + 2).split('\n');
|
|
43
|
-
const has = tail.length > 0 && tail.every(l => TRAILER_RE.test(l));
|
|
44
|
-
const trailers = {};
|
|
45
|
-
if (has) {
|
|
46
|
-
for (const l of tail) {
|
|
47
|
-
const [, k, v] = TRAILER_RE.exec(l);
|
|
48
|
-
const key = k.toLowerCase();
|
|
49
|
-
trailers[key] = [...(trailers[key] ?? []), v.trim()];
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
const head = has ? text.slice(0, cut) : text;
|
|
53
|
-
const nl = head.indexOf('\n');
|
|
54
|
-
const subject = (nl < 0 ? head : head.slice(0, nl)).trim();
|
|
55
|
-
const bad = [...KNOWN].filter(k => (trailers[k]?.length ?? 0) > 1).map(k => `duplicate ${k}`);
|
|
56
|
-
const get = (k) => trailers[k]?.[0] ?? null;
|
|
57
|
-
const ids = (v) => v === null ? null : [...new Set(v.split(',').map(x => x.trim()))];
|
|
58
|
-
const to = get('to') === '*' ? ['*'] : ids(get('to'));
|
|
59
|
-
const assign = ids(get('assign'));
|
|
60
|
-
// Roles: `<id>=<label>, …`; the label `none` clears one.
|
|
61
|
-
const pairs = get('roles') === null ? null : get('roles').split(',').map(x => x.trim().split('=').map(y => y.trim()));
|
|
62
|
-
if (pairs && !pairs.every(p => p.length === 2 && ID_RE.test(p[0]) && TOKEN_RE.test(p[1])))
|
|
63
|
-
bad.push('malformed Roles');
|
|
64
|
-
if (!subject)
|
|
65
|
-
bad.push('empty subject');
|
|
66
|
-
if (Buffer.byteLength(raw) > TEXT_MAX)
|
|
67
|
-
bad.push('text over 64 KiB');
|
|
68
|
-
if (!has)
|
|
69
|
-
bad.push('no trailer block');
|
|
70
|
-
else if (!to)
|
|
71
|
-
bad.push('no To');
|
|
72
|
-
else if (to[0] !== '*' && !to.every(x => ID_RE.test(x)))
|
|
73
|
-
bad.push('malformed To');
|
|
74
|
-
if (assign && !assign.every(x => ID_RE.test(x)))
|
|
75
|
-
bad.push('malformed Assign');
|
|
76
|
-
if (get('re') !== null && !isRef(get('re')))
|
|
77
|
-
bad.push('malformed Re');
|
|
78
|
-
if (get('hop') !== null && !HOP_RE.test(get('hop')))
|
|
79
|
-
bad.push('malformed Hop');
|
|
80
|
-
// A state is a token; whether the room's profile knows it is the store's check.
|
|
81
|
-
if (get('state') !== null && !TOKEN_RE.test(get('state')))
|
|
82
|
-
bad.push('malformed State');
|
|
83
|
-
if (get('kind') !== null && !TOKEN_RE.test(get('kind')))
|
|
84
|
-
bad.push('malformed Kind');
|
|
85
|
-
const ok = !bad.length;
|
|
86
|
-
return {
|
|
87
|
-
subject,
|
|
88
|
-
body: nl < 0 ? '' : head.slice(nl + 1).replace(/^\n+/, '').trimEnd(),
|
|
89
|
-
// A malformed message is read as if it had no trailers.
|
|
90
|
-
to: ok ? to : [],
|
|
91
|
-
assign: ok ? assign : null,
|
|
92
|
-
roles: ok && pairs ? Object.fromEntries(pairs) : null,
|
|
93
|
-
re: ok ? get('re') : null,
|
|
94
|
-
kind: ok ? get('kind') : null,
|
|
95
|
-
state: ok ? get('state') : null,
|
|
96
|
-
hop: ok && get('hop') !== null ? Number(get('hop')) : 0,
|
|
97
|
-
bad: bad.join(', ') || null,
|
|
98
|
-
trailers,
|
|
99
|
-
};
|
|
100
|
-
};
|
|
101
|
-
export const compose = (text, trailers) => `${text}\n\n${trailers.filter(([, v]) => v).map(([k, v]) => `${k}: ${v}`).join('\n')}\n`;
|
|
102
|
-
// A client refuses to write what readers would drop or ignore (§3).
|
|
103
|
-
export const checkOutgoing = (text, isRef) => {
|
|
104
|
-
const d = decodeText(Buffer.from(text));
|
|
105
|
-
if (d.invalid !== undefined)
|
|
106
|
-
fail(`refusing to send: ${d.invalid}`);
|
|
107
|
-
const m = parse(d.text, isRef);
|
|
108
|
-
if (m.bad)
|
|
109
|
-
fail(`refusing to send a malformed message: ${m.bad}`);
|
|
110
|
-
return m;
|
|
111
|
-
};
|
|
112
|
-
// --- threads (§5) ---
|
|
113
|
-
// Resolves Re and computes effective hops. Invalid messages are absent: a Re naming one does not resolve.
|
|
114
|
-
export const link = (logs) => {
|
|
115
|
-
const all = new Map();
|
|
116
|
-
for (const msgs of logs.values())
|
|
117
|
-
for (const m of msgs)
|
|
118
|
-
if (!m.invalid)
|
|
119
|
-
all.set(m.id, m);
|
|
120
|
-
for (const m of all.values())
|
|
121
|
-
m.reId = m.re && all.has(m.re) ? m.re : null;
|
|
122
|
-
const eff = new Map();
|
|
123
|
-
for (const m of all.values()) {
|
|
124
|
-
const chain = [];
|
|
125
|
-
for (let x = m; x && !eff.has(x.id) && chain.length < 100000; x = x.reId ? all.get(x.reId) : undefined)
|
|
126
|
-
chain.push(x);
|
|
127
|
-
for (let i = chain.length - 1; i >= 0; i--) {
|
|
128
|
-
const c = chain[i];
|
|
129
|
-
eff.set(c.id, Math.max(c.hop, c.reId ? eff.get(c.reId) + 1 : c.re ? 1 : 0));
|
|
130
|
-
}
|
|
131
|
-
m.hopEff = eff.get(m.id);
|
|
132
|
-
}
|
|
133
|
-
return all;
|
|
134
|
-
};
|
|
135
|
-
// Kahn's order: the answered message before the answer, earlier before later within one log; among the ready ones,
|
|
136
|
-
// the smallest (time, id) goes first.
|
|
137
|
-
export const ordered = (list) => {
|
|
138
|
-
const byId = new Map(list.map(m => [m.id, m]));
|
|
139
|
-
const next = new Map(list.map(m => [m.id, []]));
|
|
140
|
-
const indeg = new Map(list.map(m => [m.id, 0]));
|
|
141
|
-
const edge = (a, b) => {
|
|
142
|
-
next.get(a.id).push(b);
|
|
143
|
-
indeg.set(b.id, indeg.get(b.id) + 1);
|
|
144
|
-
};
|
|
145
|
-
const last = new Map();
|
|
146
|
-
for (const m of [...list].sort((a, b) => a.seq - b.seq)) {
|
|
147
|
-
if (last.has(m.from))
|
|
148
|
-
edge(last.get(m.from), m);
|
|
149
|
-
last.set(m.from, m);
|
|
150
|
-
if (m.reId && byId.has(m.reId))
|
|
151
|
-
edge(byId.get(m.reId), m);
|
|
152
|
-
}
|
|
153
|
-
const ready = list.filter(m => !indeg.get(m.id));
|
|
154
|
-
const res = [];
|
|
155
|
-
while (ready.length) {
|
|
156
|
-
ready.sort((a, b) => a.time - b.time || (a.id < b.id ? -1 : 1));
|
|
157
|
-
const m = ready.shift();
|
|
158
|
-
res.push(m);
|
|
159
|
-
for (const n of next.get(m.id)) {
|
|
160
|
-
indeg.set(n.id, indeg.get(n.id) - 1);
|
|
161
|
-
if (!indeg.get(n.id))
|
|
162
|
-
ready.push(n);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
return res;
|
|
166
|
-
};
|
|
167
|
-
export const chainHas = (all, m, top) => {
|
|
168
|
-
for (let x = m, i = 0; x && i < 10000; x = x.reId ? all.get(x.reId) : undefined, i++)
|
|
169
|
-
if (x === top)
|
|
170
|
-
return true;
|
|
171
|
-
return false;
|
|
172
|
-
};
|
|
173
|
-
export const rootOf = (all, m) => {
|
|
174
|
-
let x = m;
|
|
175
|
-
for (let i = 0; x.reId && all.has(x.reId) && i < 10000; i++)
|
|
176
|
-
x = all.get(x.reId);
|
|
177
|
-
return x;
|
|
178
|
-
};
|
|
179
|
-
export const under = (all, top) => ordered([...all.values()].filter(m => chainHas(all, m, top)));
|
|
180
|
-
export const lookup = (all, ref) => {
|
|
181
|
-
const key = String(ref ?? '').toLowerCase();
|
|
182
|
-
if (all.has(key))
|
|
183
|
-
return all.get(key);
|
|
184
|
-
const hits = key.length >= 4 ? [...all.keys()].filter(k => k.startsWith(key)) : [];
|
|
185
|
-
if (hits.length === 1)
|
|
186
|
-
return all.get(hits[0]);
|
|
187
|
-
return fail(hits.length ? `ambiguous message id ${ref}` : `unknown message ${ref}`);
|
|
188
|
-
};
|
|
189
|
-
// --- reading (§6) and waking (§7) ---
|
|
190
|
-
// Delivered: well-formed, not a hidden kind, addressed to `id` by name or `*`.
|
|
191
|
-
export const visible = (m, id, hidden) => !m.invalid && !m.bad && !(m.kind && hidden.has(m.kind)) && (m.to.includes(id) || m.to.includes('*'));
|
|
192
|
-
// Wakes: only a direct address. Broadcasts are read when the agent is awake for another reason.
|
|
193
|
-
export const wakes = (m, id, hidden) => visible(m, id, hidden) && m.to.includes(id);
|
|
194
|
-
// Messages for `id` after the per-log cursors; cursors advance only past what was shown.
|
|
195
|
-
export const unread = (logs, id, cursors, limit = Infinity, hidden) => {
|
|
196
|
-
const fresh = [];
|
|
197
|
-
for (const [log, msgs] of logs) {
|
|
198
|
-
if (log === id)
|
|
199
|
-
continue;
|
|
200
|
-
const at = msgs.findIndex(m => m.id === cursors[log]);
|
|
201
|
-
fresh.push(...msgs.slice(at + 1).filter(m => visible(m, id, hidden)));
|
|
202
|
-
}
|
|
203
|
-
const queue = ordered(fresh);
|
|
204
|
-
const shown = queue.slice(0, limit);
|
|
205
|
-
const seen = new Set(shown.map(m => m.id));
|
|
206
|
-
const next = { ...cursors };
|
|
207
|
-
for (const [log, msgs] of logs) {
|
|
208
|
-
if (log === id)
|
|
209
|
-
continue;
|
|
210
|
-
const at = msgs.findIndex(m => m.id === cursors[log]);
|
|
211
|
-
for (const m of msgs.slice(at + 1)) {
|
|
212
|
-
if (visible(m, id, hidden) && !seen.has(m.id))
|
|
213
|
-
break;
|
|
214
|
-
next[log] = m.id;
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
return { msgs: shown, rest: queue.length - shown.length, cursors: next };
|
|
218
|
-
};
|
|
219
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
// reader: what one reader on this machine accepted of a room: heads, signals, cursors, alarms. Only history that
|
|
2
|
-
// extends what it accepted before, verified by the store, is delivered (docs/spec/hub-1.md, Trust).
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
import * as Signals from '../domain/signals.js';
|
|
5
|
-
import { HOME, locked, readJson, writeJson } from '../home/index.js';
|
|
6
|
-
import { toMessage } from '../hub/index.js';
|
|
7
|
-
import { fail, note, short } from '../lib/index.js';
|
|
8
|
-
import { link } from '../protocol/index.js';
|
|
9
|
-
export const readerFile = (R, reader) => path.join(HOME, 'readers', R.hub.name, R.genesis, `${reader}.json`);
|
|
10
|
-
export const readerLock = (R, reader, fn) => locked(`reader-${R.hub.name}-${R.genesis.slice(0, 12)}-${reader}`, fn);
|
|
11
|
-
export const loadState = (R, reader) => readJson(readerFile(R, reader), {});
|
|
12
|
-
export const saveState = (R, reader, st) => writeJson(readerFile(R, reader), st);
|
|
13
|
-
// Every log must keep extending what this reader accepted, and the store must verify it (a signed store: every entry
|
|
14
|
-
// signed by the key the room admitted). A log that lost, rewrote or forked accepted history, or fails verification,
|
|
15
|
-
// is quarantined: withheld, its accepted head pinned as evidence. Only `ringi forget` by the operator accepts a new
|
|
16
|
-
// baseline.
|
|
17
|
-
export const loadRoomUnlocked = (R, reader) => {
|
|
18
|
-
const st = loadState(R, reader);
|
|
19
|
-
const store = R.hub.store;
|
|
20
|
-
if (st.control && !store.extends(st.control, R.head)) {
|
|
21
|
-
fail(`ALARM room ${R.name}: its control history was rewritten (accepted ${short(st.control)}, now ${short(R.head)}). Nothing is delivered; the operator decides`);
|
|
22
|
-
}
|
|
23
|
-
st.control = R.head;
|
|
24
|
-
st.heads ??= {};
|
|
25
|
-
const alarms = [...store.alarms?.(R.s) ?? []];
|
|
26
|
-
const logs = new Map();
|
|
27
|
-
for (const id of new Set([...store.logIds(R.s), ...Object.keys(st.heads)])) {
|
|
28
|
-
const cur = store.logHead(R.s, id);
|
|
29
|
-
const acc = st.heads[id];
|
|
30
|
-
const why = !cur ? `log ${id} was deleted after ${short(acc)}`
|
|
31
|
-
: acc && !store.extends(acc, cur) ? `log ${id} was rewritten: ${short(cur)} does not extend the accepted ${short(acc)}`
|
|
32
|
-
: !store.extends(R.genesis, cur) ? `log ${id} does not descend from the room's genesis`
|
|
33
|
-
: store.verifyLog(R.s, id, cur);
|
|
34
|
-
if (why) {
|
|
35
|
-
alarms.push(why.startsWith('log ') ? why : `log ${id}: ${why}`);
|
|
36
|
-
continue;
|
|
37
|
-
}
|
|
38
|
-
if (acc !== cur) {
|
|
39
|
-
st.heads[id] = cur;
|
|
40
|
-
store.pin(R.s, reader, id, cur);
|
|
41
|
-
}
|
|
42
|
-
logs.set(id, store.messages(R.s, id, cur).map((x, seq) => toMessage(R, id, x, seq)));
|
|
43
|
-
}
|
|
44
|
-
const records = store.signals(R.s);
|
|
45
|
-
const checked = Signals.check(R, link(logs), records);
|
|
46
|
-
const signalPins = Signals.pins(records, checked, st.signals);
|
|
47
|
-
st.signals = signalPins.accepted;
|
|
48
|
-
alarms.push(...signalPins.alarms, ...checked.filter(x => !x.ok).map(x => `signal ${x.ref}: ${x.why}`));
|
|
49
|
-
const reported = new Set(st.alarms ?? []);
|
|
50
|
-
for (const a of alarms)
|
|
51
|
-
if (!reported.has(a))
|
|
52
|
-
note(`ALARM ${a}; ${a.startsWith('signal ')
|
|
53
|
-
? 'the messages stay the truth; the author restores a missing signal with ringi agent signals --repair'
|
|
54
|
-
: a.startsWith('commit ') ? 'it is skipped; the room reads on without it'
|
|
55
|
-
: `it is quarantined and withheld. Restore it, or the operator runs ringi forget ${R.name}/<log>`}`);
|
|
56
|
-
st.alarms = alarms;
|
|
57
|
-
saveState(R, reader, st);
|
|
58
|
-
return { logs, st };
|
|
59
|
-
};
|
|
60
|
-
export const loadRoom = (R, reader) => readerLock(R, reader, () => loadRoomUnlocked(R, reader));
|
|
61
|
-
export const linked = (R, reader) => {
|
|
62
|
-
const { logs } = loadRoom(R, reader);
|
|
63
|
-
return { logs, all: link(logs) };
|
|
64
|
-
};
|
|
65
|
-
//# sourceMappingURL=reader.js.map
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
// session: which chat is which, and which seat it holds. A seat is one (hub, room genesis, agent); it ends only with
|
|
2
|
-
// leave or the operator's explicit takeover. Every agent command passes `bound()` first.
|
|
3
|
-
import fs from 'node:fs';
|
|
4
|
-
import path from 'node:path';
|
|
5
|
-
import crypto from 'node:crypto';
|
|
6
|
-
import { spawnSync } from 'node:child_process';
|
|
7
|
-
import { HOME, guard, locked, readJson, writeJson } from '../home/index.js';
|
|
8
|
-
import { openHub, openRoom, roomNames } from '../hub/index.js';
|
|
9
|
-
import { errno, fail, stamp } from '../lib/index.js';
|
|
10
|
-
export const LEASE = 60 * 60 * 1000;
|
|
11
|
-
const detectProduct = () => {
|
|
12
|
-
const env = process.env;
|
|
13
|
-
if (env.CLAUDECODE === '1' || env.CLAUDE_CODE_SESSION_ID)
|
|
14
|
-
return 'claude';
|
|
15
|
-
if (Object.keys(env).some(k => k.startsWith('CODEX_')))
|
|
16
|
-
return 'codex';
|
|
17
|
-
if (Object.keys(env).some(k => k.startsWith('CURSOR_')))
|
|
18
|
-
return 'cursor';
|
|
19
|
-
return null;
|
|
20
|
-
};
|
|
21
|
-
const ancestry = () => {
|
|
22
|
-
let pid = process.ppid;
|
|
23
|
-
for (let i = 0; i < 12 && pid > 1; i++) {
|
|
24
|
-
const r = spawnSync('ps', ['-o', 'ppid=,comm=', '-p', String(pid)], { encoding: 'utf8' });
|
|
25
|
-
const m = r.status === 0 ? /^\s*(\d+)\s+(.*)$/.exec(String(r.stdout ?? '').trim()) : null;
|
|
26
|
-
if (!m)
|
|
27
|
-
return null;
|
|
28
|
-
const comm = path.basename(m[2].trim()).toLowerCase();
|
|
29
|
-
if (/^(claude|codex|cursor|cursor-agent)$/.test(comm))
|
|
30
|
-
return { pid, product: comm.replace('-agent', '') };
|
|
31
|
-
pid = Number(m[1]);
|
|
32
|
-
}
|
|
33
|
-
return null;
|
|
34
|
-
};
|
|
35
|
-
// A chat is known by a stable handle: RINGI_SESSION, else the chat id the UI exposes, else the UI process as a last
|
|
36
|
-
// resort (ps may be denied in a sandbox; then RINGI_SESSION is required).
|
|
37
|
-
export const whoAmI = () => {
|
|
38
|
-
const env = process.env;
|
|
39
|
-
const product = detectProduct();
|
|
40
|
-
if (env.RINGI_SESSION)
|
|
41
|
-
return { handle: `env:${env.RINGI_SESSION}`, product, pid: null };
|
|
42
|
-
if (env.CLAUDE_CODE_SESSION_ID)
|
|
43
|
-
return { handle: `claude:${env.CLAUDE_CODE_SESSION_ID}`, product: 'claude', pid: Number(env.CLAUDE_PID) || null };
|
|
44
|
-
const a = ancestry() ?? fail('cannot tell which session this is: set RINGI_SESSION to a stable id of this chat (for Codex: its thread id) on every ringi command');
|
|
45
|
-
return { handle: `pid:${a.pid}`, product: product ?? a.product, pid: a.pid };
|
|
46
|
-
};
|
|
47
|
-
const sessionsDir = () => path.join(HOME, 'sessions');
|
|
48
|
-
const sessionFile = (handle) => path.join(sessionsDir(), `${handle.replace(/[^A-Za-z0-9._-]/g, '_').slice(0, 100)}-${crypto.createHash('sha256').update(handle).digest('hex').slice(0, 10)}.json`);
|
|
49
|
-
export const allSessions = () => {
|
|
50
|
-
let files = [];
|
|
51
|
-
try {
|
|
52
|
-
files = fs.readdirSync(sessionsDir()).filter(f => f.endsWith('.json'));
|
|
53
|
-
}
|
|
54
|
-
catch { }
|
|
55
|
-
return files.map(f => readJson(path.join(sessionsDir(), f), null)).filter((s) => !!s?.handle);
|
|
56
|
-
};
|
|
57
|
-
export const readSession = (handle) => {
|
|
58
|
-
const s = readJson(sessionFile(handle), null);
|
|
59
|
-
return s?.handle === handle ? s : null;
|
|
60
|
-
};
|
|
61
|
-
export const saveSession = (s) => writeJson(sessionFile(s.handle), s);
|
|
62
|
-
export const dropSession = (handle) => { guard(() => fs.rmSync(sessionFile(handle), { force: true })); };
|
|
63
|
-
export const pidAlive = (pid) => {
|
|
64
|
-
try {
|
|
65
|
-
process.kill(pid, 0);
|
|
66
|
-
return true;
|
|
67
|
-
}
|
|
68
|
-
catch (e) {
|
|
69
|
-
return errno(e) === 'EPERM';
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
// active: in use within the lease by a living process; stopped: paused by the operator; gone: neither. A gone or
|
|
73
|
-
// stopped binding keeps its seat and scope. A watcher is alive exactly while its process is: a run may outlast any
|
|
74
|
-
// lease.
|
|
75
|
-
export const liveness = (s) => s.state === 'stopped' ? 'stopped'
|
|
76
|
-
: s.product === 'watch' ? (s.pid && pidAlive(s.pid) ? 'active' : 'gone')
|
|
77
|
-
: Date.now() - Date.parse(s.lastSeen) < LEASE && (!s.pid || pidAlive(s.pid)) ? 'active' : 'gone';
|
|
78
|
-
export const seatHolder = (hub, genesis, agent, except) => allSessions().find(s => s.hub === hub && s.genesis === genesis && s.agent === agent && s.handle !== except);
|
|
79
|
-
// An explicit chat-to-watch handoff remembers only that chat; it never selects another chat's seat.
|
|
80
|
-
export const ownSession = (handle) => readSession(handle)
|
|
81
|
-
?? allSessions().find(s => s.product === 'watch' && s.takenFrom === handle) ?? null;
|
|
82
|
-
// The binding, checked on every agent command: joined, not stopped, room alive and the same room, still a member.
|
|
83
|
-
export const bound = () => {
|
|
84
|
-
const me = whoAmI();
|
|
85
|
-
const s = readSession(me.handle) ?? fail(`this session is not in a room. Take part only when the operator says so in this chat:
|
|
86
|
-
"join <room> as <id>" runs ringi join local <room> --as <id> --scope "<what they delegate>";
|
|
87
|
-
after a restart, "continue" runs ringi continue.`);
|
|
88
|
-
if (s.state === 'stopped')
|
|
89
|
-
fail('this session is stopped: the operator paused it. It reacts to nothing until the operator says "continue" (ringi continue)');
|
|
90
|
-
const H = openHub(s.hub);
|
|
91
|
-
const R = openRoom(H, s.room, { quiet: true });
|
|
92
|
-
if (!R || R.genesis !== s.genesis) {
|
|
93
|
-
// The room's branch is gone (deleted, archived, or deleted and made anew): the session leaves it on its own. A hub
|
|
94
|
-
// that cannot be reached fails above and leaves nothing.
|
|
95
|
-
locked('sessions', () => { if (readSession(me.handle)?.genesis === s.genesis)
|
|
96
|
-
dropSession(me.handle); });
|
|
97
|
-
const gone = roomNames(H, true).find(a => a === `${s.room}@${s.genesis.slice(0, 8)}`);
|
|
98
|
-
fail(gone ? `room ${s.room} was archived as ${gone}; this session left it`
|
|
99
|
-
: R ? `room ${s.room} was deleted and created again; this session left the old room. The operator joins it anew`
|
|
100
|
-
: `room ${s.room} is gone from hub ${s.hub}; this session left it`);
|
|
101
|
-
}
|
|
102
|
-
if (!R.members[s.agent])
|
|
103
|
-
fail(`${s.agent} was removed from room ${s.room}; returning needs a fresh join by the operator`);
|
|
104
|
-
locked('sessions', () => {
|
|
105
|
-
const cur = readSession(me.handle) ?? fail('this session lost its seat');
|
|
106
|
-
if (cur.state !== 'active' || cur.genesis !== s.genesis || cur.agent !== s.agent)
|
|
107
|
-
fail('this session was stopped or its seat changed');
|
|
108
|
-
saveSession({ ...cur, lastSeen: stamp(), pid: me.pid ?? cur.pid });
|
|
109
|
-
});
|
|
110
|
-
return { s, H, R: R, me: s.agent };
|
|
111
|
-
};
|
|
112
|
-
export const parseSelector = (sel) => {
|
|
113
|
-
const m = /^(?:([a-z0-9._-]+):)?([^/]+)\/([^/]+)$/.exec(sel ?? '');
|
|
114
|
-
return m ? { hub: m[1] ?? null, room: m[2], agent: m[3] } : fail('a session is named <room>/<agent> or <hub>:<room>/<agent>');
|
|
115
|
-
};
|
|
116
|
-
//# sourceMappingURL=session.js.map
|