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/agent-environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ A Session can outlive every client. The presence snapshot says no connection is
| §4 rule 4 Core carries no business meaning | Bodies are module projections; no core branch. |
| §4 rule 5 Batch | A snapshot is one input; the settings tool performs no write. |
| §4 rule 6 Context from consumed events | Snapshots are inputs; tool results are tool results; no second path. |
| §4 rule 7 Public services | `SessionClientsHost` and the setting modules' read ports are public. |
| §4 rule 7 Public services | `connection.presences` and the setting modules' read ports are public. |
| §4 rule 8 Infrastructure unchanged | No Timeline, Dispatcher, envelope, assembly or facade change. |
| §4 rule 9 Timeline holds decision facts | Only the delivered snapshot is an input fact; the live connection and settings stores remain outside the Timeline. |
| ADR 002 D1 | Each fact stays with its producer; parts are placed in Session or branch. |
Expand Down
2 changes: 1 addition & 1 deletion docs/design/cli-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -1901,7 +1901,7 @@ whole rule as one quoted argument, so global options stay unambiguous.
| `dimcode account PROVIDER` | Print the described account's non-secret state. |
| `dimcode logout PROVIDER` | Sign the described account out. |
| `/connect` | List the Providers `provider.management` reports; a described account opens its sign-in or sign-out step, and any other Provider opens the connection form. |
| `/report` | Report the current Session, including during a turn or when no error occurred. Save the local report ZIP, see its path, or open a share destination after saving. [Report contract](plugins/Report.md#2-client-interaction). |
| `/report` | Report the current Session, including during a turn or when no error occurred. Save the local report ZIP, see its path, or open a share destination after saving. [Report contract](plugins/Report.md#client-interaction). |
| `/exit` | Detach and exit from the idle interactive prompt. |
| `!command` / `!!command` | Call the Session's existing `shell.run` in record/private mode, including during a model turn. |
| `--permission read-only\|workspace-write\|full-access` | Select the preset of a new or resumed Session for `dimcode`, `tui`, `exec` and `exec resume` ([permission controls](#permission-controls)). |
Expand Down
4 changes: 2 additions & 2 deletions docs/design/client-ui-extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -430,8 +430,8 @@ type PreviewMethods = {

| 名称 | 范围 | 输入与结果 |
| --- | --- | --- |
| `uiExtensions` | process,后端命名服务 | 接受 PluginManager 的已验证内容注册/撤下;提供目录快照及变化观察,不供页面发布内容 |
| `uiResources` | Session,后端命名服务 | `publishFile({path, mediaType}) -> ResourceRef`;`withdraw(ref)` 等到读取结束;注册自动归调用者生命周期,调用者不能撤下其他注册 |
| `uiExtensions` | process,后端命名服务 | 操作见 [UiExtensions 契约](plugins/UiExtensions.md):按插件 id 注册/撤下内容、目录快照与变化事实,不供页面发布内容 |
| `uiResources` | Session,后端命名服务 | 操作见 [UiResources 契约](plugins/UiResources.md):`publish`/`withdraw`/`read`,引用归发布者行,调用者不能撤下其他注册 |
| `ui.extensions.list` | 已授权客户端的精确只读方法 | `{}` → `{revision, extensions, errors}`;extension 包含插件名、generation 和面板声明,不含 URL;errors 仅含 UiExtensions 自己产生的内容错误且不含绝对路径 |
| `ui.extensions.read` | 已授权客户端的精确只读方法(local) | `{generation, path, offset?, limit?}` → `{offset, bytes, total, mediaType, data}`;`data` 为标准 base64;默认 1 MiB、上限 4 MiB;不在 `WEB_MANAGEMENT_METHODS` |
| `session.ui.resources.read` | UiResources part 注册的 Session 方法 | `{sessionId, id, offset?, limit?}` → `{offset, bytes, total, mediaType, data}`;同一页边界;经 `session.methods` 发现;id 只在发布它的 Session 实例内有效 |
Expand Down
6 changes: 3 additions & 3 deletions docs/design/contracts/process-owner-operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ The target removes `sessionPermissions`, `selectableModelsHost`, `modelSelection
| 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. |
| 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. |
| UI clients → UiHost / UiExtensions | Existing `ui.open/attach/replace/status/shutdown/close` RPCs and [extension listing, resources and notices](../client-ui-extensions.md). Transport supplies the authenticated connection identity. UiHost owns attach tokens, generations and disconnect cleanup. |
| Presence consumers → Connection | `connection.presences` ([Connection](../plugins/Connection.md)). Connection serves this operation directly and handles broadcast, socket registration, writes, close and detach. |
| Activity consumers / daemon clients → ServerControl | `processActivity.activated/closing/hold/release/holds/shutdown/fault` ([ServerControl](../plugins/ServerControl.md)); existing `daemon.ping/shutdown` RPCs. Shutdown settles the initiating reply before transport teardown. |
| UI clients → UiHost / UiExtensions | Existing `ui.open/attach/replace/status/shutdown/close` RPCs ([UiHost](../plugins/UiHost.md)) and [extension listing, resources and notices](../client-ui-extensions.md) ([UiExtensions](../plugins/UiExtensions.md), [UiResources](../plugins/UiResources.md)). Transport supplies the authenticated connection identity. |
| Prompt, scenario and summary evaluation tools → active profile | Use `providerService` for their catalog/selection calls and `modelHost.invoke` for execution. |
| Media execution and realtime → native adapter | Existing native connection binding and credential owner ([#1613](https://github.com/arcships/dim/issues/1613), [#1634](https://github.com/arcships/dim/issues/1634)). |
| Transport, Web entry and Session subscriptions → Connection | Connection-owned attach, broadcast, close and detach using the authenticated connection identity. |
Expand Down
20 changes: 8 additions & 12 deletions docs/design/contracts/session-boundary.md
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ Session namespaces registered today: `session.question` (Questions), `session.go

### A.2 Call channel

`progress`, `notify` and `closed` are implemented (C1, #1158); `takeFinalReply` is not. App Server provides the process service `callChannel` to method providers, from its own `CallChannel` row so that a row naming it does not reload with Rpc; the Rust binding is the handler's per-call `Progress` and `Caller` (Appendix F).
`progress`, `notify` and `closed` are implemented (C1, #1158); `takeFinalReply` is not. App Server provides the process service `callChannel` to method providers, from its own `CallChannel` row so that a row naming it does not reload with Rpc; the Rust binding is the handler's per-call `Progress` and the [CallChannel contract](../plugins/CallChannel.md)'s `notify`/`progress`/`closed` with `{connectionId, callId}` (Appendix F).

| Method | Mode | Request | Reply |
| --- | --- | --- | --- |
Expand Down Expand Up @@ -564,7 +564,7 @@ The neutral services map to the native owners below. Tools register with ToolReg
| `managementMethods` | `ManagementMethods`, a process service holding a `MethodTable`, provided by App Server's `ManagementMethodsPlugin` row | A process part depends on `Keyed<ManagementMethods>` and calls `methods.register(ctx, ns, Vec<MethodDecl>, Handler)` in its `apply` | Rpc depends on the table and reads it per call (`management_provider`, §3.2), with row status from `loader.get(row)`; no provider is in Rpc's `Deps` | Implemented (#14, #382) |
| `sessionMethods` | `SessionMethods`, a Session service holding a `MethodTable`, provided by the `SessionMethodsPlugin` Session part; its check is the process value `ReservedMethods` App Server provides | A Session part depends on `Keyed<SessionMethods>` and calls `methods.register(ctx, ns, Vec<MethodDecl>, Handler)` in its `apply` | Per call: `Session::session_service::<SessionMethods>()` on the Session `sessionId` names, after `index.acquire`, then `session_provider` (A.1); no provider is in Rpc's `Deps` | Implemented (C1, #382) |
| Tool registration | `ToolContribution {definition, handler}`, registered with the Session's `ToolRegistry` (`Keyed<ToolRegistry>`) | `tools.register(ctx, ToolContribution)` in the part's `apply`; a dynamic source uses `tools.register_source(ctx, name, provider)` | Every read takes in what is registered; a name the mount list gives that nothing has registered is omitted and reported in diagnostics; each registration is a registry-owned versioned set (A.5, #241) | Implemented (#382) |
| `callChannel` | `progress`: the handler's `Progress` argument, one per call; `notify` and `closed`: the `Caller` of the handler's `MethodCall.origin`, one per call; for other languages the process service `callChannel` | — | Rpc gives each admitted call a sink to its calling connection; the index records a foreign call by its `callId` until its reply is written, and removes the connection's entries on close or unload | `progress`, `notify` and `closed` implemented (C1, #1158); `takeFinalReply` not implemented |
| `callChannel` | `progress`: the handler's `Progress` argument, one per call; `notify` and `closed`: `{connectionId, callId}` from the handler's `MethodCall.origin`, per call; for other languages the process service `callChannel` | — | Rpc gives each admitted call a sink to its calling connection; the CallChannel entry records the row instance and connection until the connection closes, the Rpc load unloads or the row unloads | `progress`, `notify` and `closed` implemented (C1, #1158); `takeFinalReply` not implemented |

```rust
// crates/dim-agent-capabilities/src/methods.rs (C1), shared by both services
Expand Down Expand Up @@ -618,19 +618,15 @@ pub struct ManagementMethods(pub Arc<MethodTable>); // Deref<Target = MethodTabl
```rust
// crates/dim-agent-capabilities/src/methods.rs, shared by both services
pub struct MethodCall { pub method: String, pub params: Value, pub origin: Origin }
pub struct Origin { pub caller: Option<Caller> }
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum NotifyError { Undeclared, Gone, TooLarge } // code(): "undeclared", "gone", "too_large"
impl Caller {
pub fn id(&self) -> &str; // the contract's connectionId
pub fn notify(&self, method: &str, params: serde_json::Map<String, Value>) -> Result<(), NotifyError>;
pub fn closed(&self) -> impl Future<Output = ()> + Send + 'static;
}
pub struct Origin { pub caller: Option<CallerRef> }
#[derive(Clone, Debug)]
pub struct CallerRef { pub connection_id: String, pub call_id: String }
// notify/progress/closed are the operations of the CallChannel contract.
```

`Caller` binds A.2 `notify` and `closed` per call, like `Progress`: `MethodProvider::accept` builds it only when the call arrived on a client connection, bound to the notifications its declaration set declared, so a name outside that set is `Undeclared` before anything is written, and a generation that has unloaded is `Gone` first. It holds the connection through a trait object (`CallerConnection`) that keeps no strong reference to it, so a provider that keeps a `Caller` does not keep a closed connection alive. Rpc writes each notification after the reply of the call that produced the caller: one sent while the call runs is encoded once, admitted under the connection's held allowance, held in order and flushed right after the reply; one over the frame limit is `TooLarge` and the connection stays open, and one the held allowance cannot take closes the connection as a slow consumer. The caller resolves `closed` when the connection closes or the admitting Rpc load unloads.
`Caller` and `Callers` are replaced by the [CallChannel contract](../plugins/CallChannel.md): the provider keeps `{connectionId, callId}` and calls `notify`, `progress` and `closed`, and `run` binds the call around the table dispatch. The delivery rules above — declared before gone, after-reply ordering, the held allowance, `unsupported`/`undeclared`/`gone`/`too_large` and the lifetime of the entry — are unchanged; the binding holds no connection handle.

`Callers` is private transport wiring shared by the CallChannel and Rpc rows at its Rust type key; it has no service catalog name. The public operation surface remains `callChannel`. `Callers` is the process's only caller index: per row instance it holds the notification names its generation declared, kept after a connection of that instance closes so `Undeclared` is decided before `Gone`, and per row instance and connection the connection's direct writer and the row's unfinished calls by `callId`. `MethodProvider::accept` mints a foreign call's `callId` where the call's sink, the instance and the provider's declarations meet, and records the call; `Connection::answer` removes it after the reply is written. The entries of a connection are removed when it closes, when the admitting Rpc load unloads and when the row's generation unloads; the declared names go with the instance's generation. A native provider keeps its own `Caller` and records nothing. App Server provides A.2 `callChannel` for other languages as the process service `callChannel` (`ForeignCallChannel`, at `host_key("callChannel")`, from the `CallChannel` row that has no dependencies): its `notify` and `closed` read the calling row's instance with `rutis_bridge::session::caller_row()` and end in the same call's sink the Rust binding uses, so both bindings share one delivery path.
`Callers` has no service catalog name; the public operation surface is `callChannel`.

The foreign `register` (`ForeignMethods`, shared by both tables) decodes the declarations once, with the required fields above. It calls `call` with `{callId, method, params}` and, when the call came from a connection, `origin: {connectionId}`, a cancellation Promise and a per-call progress callback, and decodes `{kind:"value", value}` or a `{code, message}` error, whose `code` is the `appError`; an omitted `value`, including JavaScript `undefined` omitted by JSON serialization, becomes JSON `null`. A method may instead rethrow a service error it received. Unsupported declaration/reply fields and malformed data fail at this boundary. Not implemented: final-reply handoff, `origin.entry` and `origin.peer`, and the `reply` declaration field.

Expand Down
2 changes: 1 addition & 1 deletion docs/design/examples/timeline-capability-analysis.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@

- **场景/状态**:当前客户端 presence 的字符串快照和本代 last;输入只是声称的客户端环境,不授予信任或权限。
- **转换**:先注册 ClientsChanged listener,再在 activation 后读当前值;变化才 append 自己的 input/message,成功后更新 last;关闭/代取消结束任务。
- **恢复**:重新读 SessionClientsHost 当前状态,不恢复已断开的客户端;last 清空允许本代再次报告当前值。
- **恢复**:重新读 `connection.presences` 当前状态,不恢复已断开的客户端;last 清空允许本代再次报告当前值。
- **性质/论证**:先监听再初读避免丢初值期间的改变,notify 合并后重读当前值而不是逐个回放连接通知。失败 append 不更新 last,但这里没有定时 retry,直到下次唤醒才再试;不能承诺无新信号时必然重试成功。
- **对应**:[environment_clients.rs](../../../crates/dim-agent-capabilities/src/environment_clients.rs);environment_clients。它只写采用输入,按现有行为更接近输入发布部件,不为它增加恢复状态机。

Expand Down
Loading