ask-session-protocol 0.2.0
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.
- checksums.yaml +7 -0
- data/CHANGELOG.md +58 -0
- data/LICENSE +21 -0
- data/README.md +137 -0
- data/docs/ask-session-protocol.schema.json +1428 -0
- data/lib/ask/session_protocol/client.rb +260 -0
- data/lib/ask/session_protocol/events.rb +322 -0
- data/lib/ask/session_protocol/host.rb +81 -0
- data/lib/ask/session_protocol/interactions.rb +139 -0
- data/lib/ask/session_protocol/methods.rb +393 -0
- data/lib/ask/session_protocol/schema.rb +117 -0
- data/lib/ask/session_protocol/version.rb +7 -0
- data/lib/ask/session_protocol.rb +37 -0
- data/lib/ask-session-protocol.rb +3 -0
- metadata +127 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 22436fe459ec2c7e91ed8d5c12db05a72d01daaa83794536882d094b084b9b08
|
|
4
|
+
data.tar.gz: d512c1dea2ebdfbce2ba971d00d4430431b020ee79911fc26585d3ff2aefe0e9
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: a4f4a7094797aa9acb3293ef0ab96b69dcdc238b93ed378f32090327605931780cfb3a7c96bdca45d4466fe6b2ba3d90214be360eb03204aa4480b3b93b85eca
|
|
7
|
+
data.tar.gz: 60bfed82e8fd6a6c852e04afa5c0682c0bb2a4a7fd5e790a1d5e51bb204f6f9343e2d9f9de47f6717e4ede694e6410b559c1ebc0e640e9238393aecd3c33aa7a
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to ask-session-protocol are documented here, following
|
|
4
|
+
the keep-a-changelog format.
|
|
5
|
+
|
|
6
|
+
## [Unreleased]
|
|
7
|
+
|
|
8
|
+
## [0.2.0] - 2026-08-12
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **`Client`** — NDJSON protocol client over the host's stdio or a unix
|
|
13
|
+
socket: request/response correlation by id, notification queue, error
|
|
14
|
+
handling, and connection-close semantics.
|
|
15
|
+
- **`Host`** — spawns `ask-app-server` as a subprocess (with a unique
|
|
16
|
+
per-spawn socket by default) or attaches to a running host over its
|
|
17
|
+
socket.
|
|
18
|
+
|
|
19
|
+
### Changed
|
|
20
|
+
|
|
21
|
+
- The client and host moved into this gem from the retired
|
|
22
|
+
ask-session-client (never published): one place for the session
|
|
23
|
+
protocol, matching the ask-acp/ask-mcp pattern of protocol gems
|
|
24
|
+
carrying their implementations. The JSON Schema artifact remains the
|
|
25
|
+
cross-language contract.
|
|
26
|
+
|
|
27
|
+
## [0.1.0] - 2026-08-11
|
|
28
|
+
|
|
29
|
+
### Added
|
|
30
|
+
|
|
31
|
+
- **Canonical event vocabulary (19 types)** — `session.created/ended`,
|
|
32
|
+
`turn.started/completed/failed/aborted`, `model.streaming/thinking`,
|
|
33
|
+
`tool.use/delta/result`, `approval.required/updated`,
|
|
34
|
+
`plan.proposed/approved/rejected`, `todos.updated`, `file.changed`,
|
|
35
|
+
`error`. Every event validates its envelope (`type`/`seq`/`payload`)
|
|
36
|
+
and payload against the registry; unknown payload fields are allowed for
|
|
37
|
+
forward compatibility.
|
|
38
|
+
- **Resolvable interactions** — `approval`, `plan`, and `user_input`
|
|
39
|
+
kinds with `pending/approved/rejected/responded/expired` statuses,
|
|
40
|
+
resolvable by id from any client (terminal, web console, bot).
|
|
41
|
+
- **Method surface (21 methods)** — handshake (`ping`, `initialize`),
|
|
42
|
+
session lifecycle (`session/create|list|resume|subscribe|events|send|
|
|
43
|
+
abort|close`), artifacts, interactions (`interaction/list|approve|reject|
|
|
44
|
+
approve-all|reject-all|respond`), plan mode (`plan/approve|reject`), and
|
|
45
|
+
`workspace/readState`; params and results validated against the registry.
|
|
46
|
+
- **Interop surface** — `interaction/requestPermission` and
|
|
47
|
+
`interaction/requestUserInput` reverse requests, matching the external
|
|
48
|
+
app-server protocol standard.
|
|
49
|
+
- **Versioning** — `PROTOCOL_VERSION` (`1.0`, semver semantics: additive
|
|
50
|
+
changes bump minor, breaking changes bump major) negotiated in
|
|
51
|
+
`initialize`; `DELIVERY_KINDS` (`live`, `replay`,
|
|
52
|
+
`web-remote-replayable`).
|
|
53
|
+
- **JSON Schema artifact** — `docs/ask-session-protocol.schema.json`
|
|
54
|
+
(draft 2020-12) generated from the registries via `rake schema`, so
|
|
55
|
+
non-Ruby clients can validate the contract without loading the gem.
|
|
56
|
+
- **Test suite** — 64 minitest tests covering event/interaction/method
|
|
57
|
+
validation, round-trips, registry integrity, schema generation, and
|
|
58
|
+
gemspec metadata.
|
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Kaka Ruto
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# ask-session-protocol
|
|
2
|
+
|
|
3
|
+
**The canonical wire protocol for ask agent sessions.**
|
|
4
|
+
|
|
5
|
+
The contract between the ask session host (ask-app-server) and every client:
|
|
6
|
+
terminal TUI, web console, bots, IDE integrations, CI scripts. One runtime,
|
|
7
|
+
many thin clients — all speaking the same versioned vocabulary.
|
|
8
|
+
|
|
9
|
+
This gem is a **definition, not an implementation**. It contains no runtime,
|
|
10
|
+
no transports, and no session logic. It is the single authoritative,
|
|
11
|
+
versioned artifact for what a session event looks like on the wire and which
|
|
12
|
+
methods a host exposes — so the host and every client evolve independently
|
|
13
|
+
against the same contract.
|
|
14
|
+
|
|
15
|
+
## Why this exists
|
|
16
|
+
|
|
17
|
+
The ask ecosystem previously translated `Ask::Agent` runtime events into
|
|
18
|
+
three incompatible wire shapes (app-server events, harness SSE events,
|
|
19
|
+
adapter events). ask-session-protocol replaces that drift with one canonical,
|
|
20
|
+
versioned vocabulary, generated JSON Schema artifacts, and strict validation
|
|
21
|
+
at the boundaries.
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
┌───────────────────────────────────────────┐
|
|
25
|
+
│ ask-agent (session runtime) │
|
|
26
|
+
└──────────────┬────────────────────────────┘
|
|
27
|
+
│
|
|
28
|
+
┌────────────────────▼────────────────────┐
|
|
29
|
+
│ ask-session-protocol ← this gem │
|
|
30
|
+
│ events · interactions · methods │
|
|
31
|
+
│ versions · JSON Schema │
|
|
32
|
+
└────────────────────┬────────────────────┘
|
|
33
|
+
│ the only crossing artifact
|
|
34
|
+
┌────────────────────▼────────────────────┐
|
|
35
|
+
│ ask-app-server (THE HOST) │
|
|
36
|
+
│ transports: in-process | stdio | │
|
|
37
|
+
│ unix socket | SSE │
|
|
38
|
+
└───┬───────────┬───────────┬─────────────┘
|
|
39
|
+
terminal TUI web console bots/IDE
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## The event envelope
|
|
43
|
+
|
|
44
|
+
Every event on the wire has the same shape:
|
|
45
|
+
|
|
46
|
+
```json
|
|
47
|
+
{ "type": "model.streaming", "seq": 12, "payload": { "delta": "Hello" } }
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
* **type** — one of the canonical dot-names below (additive growth only;
|
|
51
|
+
clients must tolerate unknown types within a major protocol version)
|
|
52
|
+
* **seq** — monotonically increasing per session; clients use it for
|
|
53
|
+
ordering, dedup, and replay
|
|
54
|
+
* **payload** — the event body, string-keyed, validated against the registry
|
|
55
|
+
|
|
56
|
+
## Event vocabulary (19 types)
|
|
57
|
+
|
|
58
|
+
| Category | Events |
|
|
59
|
+
| --- | --- |
|
|
60
|
+
| Session lifecycle | `session.created`, `session.ended` |
|
|
61
|
+
| Turn lifecycle | `turn.started`, `turn.completed`, `turn.failed`, `turn.aborted` |
|
|
62
|
+
| Model output | `model.streaming`, `model.thinking` |
|
|
63
|
+
| Tool execution | `tool.use`, `tool.delta`, `tool.result` |
|
|
64
|
+
| Interactions | `approval.required` ✱, `approval.updated`, `plan.proposed` ✱, `plan.approved`, `plan.rejected` |
|
|
65
|
+
| Session state | `todos.updated`, `file.changed` |
|
|
66
|
+
| Errors | `error` |
|
|
67
|
+
|
|
68
|
+
✱ — interaction events are **resolvable by id from any client** through the
|
|
69
|
+
`interaction/*` and `plan/*` methods. A terminal, web console, or bot
|
|
70
|
+
resolves the same pending interaction; the host tombstones delivery so each
|
|
71
|
+
subscriber sees it exactly once.
|
|
72
|
+
|
|
73
|
+
## Method surface (21 methods)
|
|
74
|
+
|
|
75
|
+
| Group | Methods |
|
|
76
|
+
| --- | --- |
|
|
77
|
+
| Handshake | `ping`, `initialize` |
|
|
78
|
+
| Session lifecycle | `session/create`, `session/list`, `session/resume`, `session/subscribe`, `session/events`, `session/send`, `session/abort`, `session/close` |
|
|
79
|
+
| Artifacts | `session/artifacts`, `session/artifact/get` |
|
|
80
|
+
| Interactions | `interaction/list`, `interaction/approve`, `interaction/reject`, `interaction/approve-all`, `interaction/reject-all`, `interaction/respond` |
|
|
81
|
+
| Plan mode | `plan/approve`, `plan/reject` |
|
|
82
|
+
| Workspace | `workspace/readState` |
|
|
83
|
+
|
|
84
|
+
Host → client: the `session/event` notification carries canonical event
|
|
85
|
+
envelopes. Reverse requests `interaction/requestPermission` and
|
|
86
|
+
`interaction/requestUserInput` are defined for interop with the external
|
|
87
|
+
app-server protocol standard.
|
|
88
|
+
|
|
89
|
+
## Versioning
|
|
90
|
+
|
|
91
|
+
* `Ask::SessionProtocol::PROTOCOL_VERSION` — the wire version, negotiated in
|
|
92
|
+
the `initialize` handshake. Bump the minor on additive changes (new
|
|
93
|
+
events, new methods); bump the major on breaking changes.
|
|
94
|
+
* `Ask::SessionProtocol::VERSION` — the gem version.
|
|
95
|
+
|
|
96
|
+
## Validation
|
|
97
|
+
|
|
98
|
+
The registries validate everything at the boundary:
|
|
99
|
+
|
|
100
|
+
```ruby
|
|
101
|
+
event = Ask::SessionProtocol::Events.event(
|
|
102
|
+
type: "approval.required",
|
|
103
|
+
seq: 3,
|
|
104
|
+
payload: { "id" => "act_1", "toolName" => "bash", "args" => { "command" => "ls" } }
|
|
105
|
+
)
|
|
106
|
+
event.to_h # => { "type" => "approval.required", "seq" => 3, "payload" => { ... } }
|
|
107
|
+
|
|
108
|
+
Ask::SessionProtocol::Methods.validate_params!("session/send", { "sessionId" => "s1", "content" => "hi" })
|
|
109
|
+
# => true
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Unknown payload fields are allowed (forward compatibility); missing required
|
|
113
|
+
fields, wrong types, and out-of-enum values raise `ArgumentError`.
|
|
114
|
+
|
|
115
|
+
## JSON Schema
|
|
116
|
+
|
|
117
|
+
`docs/ask-session-protocol.schema.json` (draft 2020-12) is generated from the
|
|
118
|
+
registries with `rake schema` and committed, so non-Ruby clients (bots, IDEs,
|
|
119
|
+
) can validate against the contract without loading this gem.
|
|
120
|
+
|
|
121
|
+
## Installation
|
|
122
|
+
|
|
123
|
+
```ruby
|
|
124
|
+
gem "ask-session-protocol"
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Development
|
|
128
|
+
|
|
129
|
+
```
|
|
130
|
+
bundle install
|
|
131
|
+
rake test # minitest suite
|
|
132
|
+
rake schema # regenerate docs/ask-session-protocol.schema.json
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## License
|
|
136
|
+
|
|
137
|
+
MIT
|