Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/design/acp-gateway-implementation.md
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ Core README 在 capability catalog 中提到 sessionConfig,但固定版本的

**Startup config**:在 native 写入之前解析 `{version:1,modelId?,configOptionValues}`,支持 model、mode、effort。未知选项返回参数错误,data.field 指明路径。modelId 优先于 configOptionValues.model,省略选项保留原生默认或既有采用值。new 用 Gateway 的候选目录解析唯一显式模型,在同一次 create 传入模型、permissionPolicy.preset 和 modelPreferences.reasoningEffort。effort 由模型所有者校验;provider-default 映射到 [原生创建 clear](model-configuration.md#clearing-one-preference),要求 daemon 声明该输入。create 以及后续 config options 都沿用模型实际采用值。

load/resume 的非空配置走 [checked attach](contracts/session-access.md#3-flows),按 attach 回复 `defaultBranch` 游标所指那条线(Session 当前默认线)的发布序号核对;fork 走 [checked fork](appserver/session-deletion-and-fork.md#61-method),按 main 上实际继承的 cut 核对。modelId 用已采用的精确 ID 比较,mode 用许可 preset,effort 用已采用的偏好值;provider-default 对照该位置已采用的模型声明与协议核对声明默认 effort。声明无法提供可用默认值时,核对该位置未采用 effort。不同值返回 session_config_mismatch,缺少相应 daemon feature 则返回 unsupported_control。等价配置不触发 setter 或 Provider 写入。相同检查条件的并发 load/resume 可合并;不同条件走 session_busy。回复使用原生实际配置。空 metadata 的建立与断线恢复沿用普通调用。
load/resume 的非空配置走 [checked attach](contracts/session-access.md#2-attach-expectations),按 attach 回复 `defaultBranch` 游标所指那条线(Session 当前默认线)的发布序号核对;fork 走 [checked fork](appserver/session-deletion-and-fork.md#61-method),按 main 上实际继承的 cut 核对。modelId 用已采用的精确 ID 比较,mode 用许可 preset,effort 用已采用的偏好值;provider-default 对照该位置已采用的模型声明与协议核对声明默认 effort。声明无法提供可用默认值时,核对该位置未采用 effort。不同值返回 session_config_mismatch,缺少相应 daemon feature 则返回 unsupported_control。等价配置不触发 setter 或 Provider 写入。相同检查条件的并发 load/resume 可合并;不同条件走 session_busy。回复使用原生实际配置。空 metadata 的建立与断线恢复沿用普通调用。

**Background exec**:直接消费已提交的 `exec/started` / `exec/ended`,来源是现有 [BackgroundExec](../../crates/dim-agent-capabilities/src/workspace_tools/background.rs),不另造 task 业务服务。开始时生成与发起工具不同的稳定 ACP toolCallId,并以 parentToolCallId 关联;这样原工具因转后台返回 completed 后,不会被重新改成 in_progress。任务状态开始为 in_progress,原生 completed → completed,failed/cancelled → failed 并保留真实原因,不能造 Core 不存在的 task cancelled 状态。结束通知允许发生在 prompt response 之后;不因此延长或重新打开那个 prompt。固定头回放重建投影并去重,live 后续仅处理新的 sequence。EOF/卸载只丢弃显示关联,不停止原生后台任务。

Expand Down
959 changes: 88 additions & 871 deletions docs/design/appserver/sessions-service.md

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions docs/design/contracts/process-owner-operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The target removes `sessionPermissions`, `selectableModelsHost`, `modelSelection
| Model selection, pickers and auxiliary callers → `providerService` | `resolve`, `selectableModels`, `selectableForModality`, `complete` keep their existing arguments and replies. Provider supplies these operations in the managed profile and ConfiguredModels in the API-key profile. |
| Media selection → Modality | `modalityTargets.resolve`. |
| Management clients → Provider / Grok OAuth / OpenAI Codex OAuth | Existing [Provider management RPCs](../appserver/provider-management.md) and account status, begin, attempt status, cancel and logout RPCs. Codex also handles its browser callback. |
| Session consumers → Agent directory | [`sessions` operations](../appserver/sessions-service.md). Agent administration and Session creation/fork retain the existing `agent.create/list/close` and `session.create/fork` client RPCs. RPC, Agent configuration, Collaboration and Provider lifecycle consumers use directory-owned admission, generation observation, close and rollback. The directory keeps the Session lease through each admitted operation. |
| Session consumers → Agents | [`sessions` operations](https://github.com/arcships/dim/pull/2098/files). Agent administration and Session creation/fork retain the existing `agent.create/list/close` and `session.create/fork` client RPCs. RPC, Agent configuration, Collaboration and Provider lifecycle consumers use Agents' admission, leases, `observe`, close and rollback. A lease is row-owned and kept across calls ([ADR 027](https://github.com/arcships/dim/pull/2029/files) D5). |
| Plugin management → loader | `rutis/loader.create/reload/remove/status`. The loader owns native profile construction and group instantiation with the original parent and group. |
| Presence consumers → Connection | `sessionClientsHost.presences`. Connection serves this operation directly and handles broadcast, socket registration, writes, close and detach. |
| Activity consumers / daemon clients → ServerControl | `processActivity.activated/hold/release`; existing `daemon.ping/shutdown` RPCs. Shutdown settles the initiating reply before transport teardown. |
Expand All @@ -22,7 +22,7 @@ The target removes `sessionPermissions`, `selectableModelsHost`, `modelSelection

| Caller → owner | Methods and replies |
| --- | --- |
| Permission consumers → Agent directory | `sessions.permission({sessionId,branchId})` and `sessions.permissionDefaults({})` retain the existing policy replies. The first holds the Session lease; the second reads the current default without creating a Session. |
| Permission consumers → Permission and Agents | A line's current policy is Permission's published value, read by `(sessionId, branchId)` id ([ADR 027](https://github.com/arcships/dim/pull/2029/files) D1); there is no `sessions.permission`. `sessions.permissionDefaults` reads the current creation default without creating a Session. |
| Dialogue, summary and suggestion → active invocation owner | `modelHost.invoke(request, mode, consume, cancelled, hooks?) → value`. Full `ModelRequest` with pinned tools, configuration, cached prefix and capability snapshot. Attempt contract below. |
| Session configuration → `providerService` (managed profile) | `configuration(explicit?, cwd?, preferences) → ModelSelection`; `applyPreferences(current, update) → ModelSelection`. Bind the existing Provider operations. |
| Session creation/adoption and Collaboration → `providerService` (managed profile) | `prepareStartup(request) → {model, admissionId?}`, `checkStartup(source) → void`, `retainStartup({sessionId, generation, model, admissionId?}) → void`, `releaseStartup({admissionId}) → void`. Reuse the pending startup binding ID. Retain on success for that Session generation; release on failure or caller unload. |
Expand All @@ -33,11 +33,11 @@ The target removes `sessionPermissions`, `selectableModelsHost`, `modelSelection

| Caller → owner | API and lifetime |
| --- | --- |
| Collaboration → sessions | `acquireUse({sessionId,agentId}) → {useId,generation}` runs the directory's existing acquire/restore and verifies the Agent before returning. Generation is the mounted Session instance ID. The directory keeps the existing SessionUse and process hold until `releaseUse({useId})` or caller unload. One lease covers delivery through request settlement, including delayed stop and idle. Failed admission releases it. |
| Collaboration → sessions | Existing input, pending, withdraw, stop and idle requests may carry the useId. For these calls the directory uses the pinned instance and retains the lease for the admitted call. `state({useId,branchId}) → BranchStatus` reads that instance's current branch state for the existing busy check. An expired use or mismatched target fails without restoring another generation. |
| Collaboration and Provider → sessions | `observeCurrent({sessionId,generation?}, onEnd) → {agentId,generation} or null`. Atomically bind to the matching loaded instance and arm its existing closed notification. No restore or idle hold. Deliver `onEnd({sessionId,agentId,generation,reason})` once, with reason `unloaded` or `closed`. The observer is owned by the caller generation; stale completions cannot remove a newer watch. |
| Agents → Collaboration and Provider | Keep `agent/session-restored` and `agent/unloaded-session-deleted`. Include the mounted generation on restored. A business close or deletion ends relations and startup ownership; idle unload preserves them. |
| Provider → sessions | `startupSources({sessionId,generation}) → StartupConnectionSource[]` projects the existing adopted startup connection references from loaded branches in that generation. Reuse the existing source type; omit branches without an adoption. No restore or credential read. Retain uses the current target and matching destinations; restore reattaches ownership. Retain is pinned to the generation supplied by its creating/adopting caller. Register observation before collecting sources; apply results only while that generation remains current. |
| Collaboration → Agents | `acquire({sessionId, agentId?}) → {leaseId, generation}` runs Agents' admission and verifies the Agent before returning; `generation` is the mounted instance. Agents keeps the lease until `release({leaseId})` or the caller row unloads. One lease covers delivery through request settlement, including a delayed stop and idle; failed admission releases it. |
| Collaboration → the line's owners | The line's input, pending, stop and published values are called by `(sessionId, line)` id ([ADR 027](https://github.com/arcships/dim/pull/2029/files) D1); no request carries a lease, and the lease only keeps the generation loaded. An expired lease or mismatched target fails without restoring another generation. |
| Collaboration and Provider → Agents | `observe({sessionId, generation?}, onEnd) → {agentId, generation} or null`, bound to the matching loaded instance; no restore or idle hold. Deliver `onEnd({sessionId, agentId, generation, reason})` once, with reason `unloaded` or `closed`. The observation is owned by the caller row; stale completions cannot remove a newer watch. |
| Agents → Collaboration and Provider | Keep `agent/session-restored` (with the mounted generation), `agent/unloaded-session-deleted` and `agent/session-deleted`. A business close or deletion ends relations and startup ownership; idle unload preserves them. |
| Provider → the line's owners | Provider reads each line's published adopted startup connection by `(sessionId, line)` id ([ADR 027](https://github.com/arcships/dim/pull/2029/files) D1); Agents provides no proxy. Omit lines without an adoption. No restore or credential read. Retain uses the current target and matching destinations; restore reattaches ownership, pinned to the generation supplied by its creating/adopting caller. Register observation before collecting sources; apply results only while that generation remains current. |

### Connection settlement

Expand Down
9 changes: 2 additions & 7 deletions docs/design/contracts/resource-owner-operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,9 @@ The OS path, pinned reader and input reader above use a path value, an existing
and a callback respectively. Existing local media submission/import, legacy node paths,
result settlement and result paging keep the [Modality contract](../plugins/Modality.md).

## Persistent Agents → sqliteStorage
## Persistent Agents → Agents

| Caller in Agents | Repository API; IDs and records are data |
| --- | --- |
| Load the directory and Session ownership | agents({}) → AgentRecord[]; owners({}) → SessionOwner[]. Keep ordered results, invalid-profile rows, ownership errors and validation of the unique default. |
| Install/forget a persisted Agent | save({id,profile,default,owner?}) and delete({id}) → void. |
| Look up delegation and decide if removal is permitted | members({}) → ordered Session/leader pairs; ledMembers({leader}), ownedAgents({owner}), memberSessions({agent}) → ordered IDs; agentOwner({agent}) → owning Session ID or null. |
| Startup repair | unfinishedOwned({}) → {incomplete,orphaned}. Preserve the existing single query and the two distinct cleanup paths. |
The Agent and member records belong to [Agents](https://github.com/arcships/dim/pull/2098/files): Agents writes them in the same creation and answers `members`; the storage engine executes the transaction and carries no face for these rows. The old `sqliteStorage.agents/save/delete/agentOwner/ownedAgents/unfinishedOwned/members/ledMembers/memberSessions` calls are removed with that move.

## Native storage

Expand Down
Loading