@theway-ai/sdk 0.1.9

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.
Files changed (60) hide show
  1. package/README.md +108 -0
  2. package/dist/client.d.ts +180 -0
  3. package/dist/client.d.ts.map +1 -0
  4. package/dist/client.js +531 -0
  5. package/dist/client.js.map +1 -0
  6. package/dist/generated/commands.d.ts +195 -0
  7. package/dist/generated/commands.d.ts.map +1 -0
  8. package/dist/generated/commands.js +633 -0
  9. package/dist/generated/commands.js.map +1 -0
  10. package/dist/generated/events.d.ts +158 -0
  11. package/dist/generated/events.d.ts.map +1 -0
  12. package/dist/generated/events.js +1122 -0
  13. package/dist/generated/events.js.map +1 -0
  14. package/dist/generated/extensions.d.ts +184 -0
  15. package/dist/generated/extensions.d.ts.map +1 -0
  16. package/dist/generated/extensions.js +1309 -0
  17. package/dist/generated/extensions.js.map +1 -0
  18. package/dist/generated/graph_engine.d.ts +422 -0
  19. package/dist/generated/graph_engine.d.ts.map +1 -0
  20. package/dist/generated/graph_engine.js +3048 -0
  21. package/dist/generated/graph_engine.js.map +1 -0
  22. package/dist/generated/health.d.ts +83 -0
  23. package/dist/generated/health.d.ts.map +1 -0
  24. package/dist/generated/health.js +179 -0
  25. package/dist/generated/health.js.map +1 -0
  26. package/dist/generated/session.d.ts +854 -0
  27. package/dist/generated/session.d.ts.map +1 -0
  28. package/dist/generated/session.js +6790 -0
  29. package/dist/generated/session.js.map +1 -0
  30. package/dist/generated/settings.d.ts +182 -0
  31. package/dist/generated/settings.d.ts.map +1 -0
  32. package/dist/generated/settings.js +324 -0
  33. package/dist/generated/settings.js.map +1 -0
  34. package/dist/generated/state.d.ts +304 -0
  35. package/dist/generated/state.d.ts.map +1 -0
  36. package/dist/generated/state.js +1391 -0
  37. package/dist/generated/state.js.map +1 -0
  38. package/dist/generated/tools.d.ts +413 -0
  39. package/dist/generated/tools.d.ts.map +1 -0
  40. package/dist/generated/tools.js +2487 -0
  41. package/dist/generated/tools.js.map +1 -0
  42. package/dist/health.d.ts +20 -0
  43. package/dist/health.d.ts.map +1 -0
  44. package/dist/health.js +62 -0
  45. package/dist/health.js.map +1 -0
  46. package/dist/index.d.ts +15 -0
  47. package/dist/index.d.ts.map +1 -0
  48. package/dist/index.js +21 -0
  49. package/dist/index.js.map +1 -0
  50. package/docs/PROTOCOL.md +129 -0
  51. package/package.json +47 -0
  52. package/proto/commands.proto +70 -0
  53. package/proto/events.proto +87 -0
  54. package/proto/extensions.proto +99 -0
  55. package/proto/graph_engine.proto +236 -0
  56. package/proto/health.proto +26 -0
  57. package/proto/session.proto +498 -0
  58. package/proto/settings.proto +79 -0
  59. package/proto/state.proto +130 -0
  60. package/proto/tools.proto +238 -0
@@ -0,0 +1,87 @@
1
+ // Event plane: unified snapshot/event stream envelope, the high-frequency
2
+ // subagent / graph-engine event increments, and the EventService RPC surface.
3
+
4
+ syntax = "proto3";
5
+ package theway.grpc.v1;
6
+
7
+ import "commands.proto";
8
+ import "session.proto";
9
+
10
+ // Unified envelope for StreamEvents / WebSocket frames.
11
+ message StreamFrame {
12
+ oneof payload {
13
+ SessionSnapshot snapshot = 1; // connection start + full resync frames
14
+ StreamEvent event = 2; // high-frequency increment
15
+ }
16
+ }
17
+
18
+ message StreamEvent {
19
+ string session_id = 7;
20
+ oneof kind {
21
+ SubagentStarted subagent_started = 1;
22
+ SubagentOutput subagent_output = 2;
23
+ SubagentMetrics subagent_metrics = 3;
24
+ SubagentCompleted subagent_completed = 4;
25
+ NodeStatus node_status = 5;
26
+ RunStatus run_status = 6;
27
+ }
28
+ }
29
+
30
+ message SubagentStarted {
31
+ string id = 1;
32
+ string agent = 2;
33
+ string source = 3;
34
+ optional string run_id = 4;
35
+ optional string node_id = 5;
36
+ }
37
+
38
+ message SubagentOutput {
39
+ string id = 1;
40
+ string chunk = 2; // high-frequency, untruncated
41
+ }
42
+
43
+ message SubagentMetrics {
44
+ string id = 1;
45
+ double tps = 2;
46
+ double cps = 3;
47
+ uint64 chars = 4;
48
+ uint64 tokens_in = 5;
49
+ uint64 tokens_out = 6;
50
+ uint64 tools_called = 7;
51
+ uint32 turn = 8;
52
+ }
53
+
54
+ message SubagentCompleted {
55
+ string id = 1;
56
+ string status = 2;
57
+ optional string error = 3;
58
+ optional uint64 duration_ms = 4;
59
+ uint64 chars = 5;
60
+ uint64 tokens_in = 6;
61
+ uint64 tokens_out = 7;
62
+ uint64 tools_called = 8;
63
+ }
64
+
65
+ message NodeStatus {
66
+ string run_id = 1;
67
+ string node_id = 2;
68
+ string status = 3;
69
+ optional string error = 4;
70
+ }
71
+
72
+ message RunStatus {
73
+ string run_id = 1;
74
+ string status = 2;
75
+ optional string error = 3;
76
+ }
77
+
78
+ message StreamEventsRequest {
79
+ // Omitted = all sessions; set = only events for this session.
80
+ optional string session_id = 1;
81
+ }
82
+
83
+ service EventService {
84
+ // Snapshot/event stream (P0: snapshot frames; P2+: event increments).
85
+ // An optional session_id filters the stream to one session.
86
+ rpc StreamEvents(StreamEventsRequest) returns (stream StreamFrame);
87
+ }
@@ -0,0 +1,99 @@
1
+ // Runtime-extension domain: client-neutral status and serialized commands.
2
+
3
+ syntax = "proto3";
4
+ package theway.grpc.v1;
5
+
6
+ import "commands.proto";
7
+
8
+ message ExtensionSnapshot {
9
+ uint64 revision = 1;
10
+ bool reload_pending = 2;
11
+ repeated ExtensionCatalogEntry catalog = 3;
12
+ repeated ExtensionDiagnostic diagnostics = 4;
13
+ repeated ExtensionCommandDescriptor commands = 5;
14
+ repeated ExtensionContribution contributions = 6;
15
+ }
16
+
17
+ message ExtensionCatalogEntry {
18
+ string extension_id = 1;
19
+ string version = 2;
20
+ string source = 3;
21
+ string scope = 4;
22
+ int32 priority = 5;
23
+ string status = 6;
24
+ repeated string permissions = 7;
25
+ optional string reason_code = 8;
26
+ }
27
+
28
+ message ExtensionDiagnostic {
29
+ string extension_id = 1;
30
+ string code = 2;
31
+ string severity = 3;
32
+ string message = 4;
33
+ optional string session_id = 5;
34
+ optional string event = 6;
35
+ optional uint64 sequence = 7;
36
+ // JSON object containing only public details. Sensitive detail values are
37
+ // absent and their names appear in redacted_fields.
38
+ string details_json = 8;
39
+ repeated string redacted_fields = 9;
40
+ }
41
+
42
+ message ExtensionCommandDescriptor {
43
+ string extension_id = 1;
44
+ string name = 2;
45
+ string label = 3;
46
+ string description = 4;
47
+ string argument_schema_json = 5;
48
+ }
49
+
50
+ // Open envelope: clients skip unrecognized kind values without decoding
51
+ // payload_json. This avoids a closed enum/oneof compatibility dependency.
52
+ message ExtensionContribution {
53
+ string contribution_id = 1;
54
+ string extension_id = 2;
55
+ string scope = 3;
56
+ string kind = 4;
57
+ string payload_json = 5;
58
+ }
59
+
60
+ message InvokeExtensionCommandRequest {
61
+ string name = 1;
62
+ string arguments_json = 2;
63
+ bool has_interactive_client = 3;
64
+ }
65
+
66
+ message ExtensionCommandOutcome {
67
+ string status = 1;
68
+ optional string code = 2;
69
+ optional string message = 3;
70
+ optional string data_json = 4;
71
+ }
72
+
73
+ message ReloadExtensionsRequest {
74
+ bool cancel_active = 1;
75
+ }
76
+
77
+ message ReloadExtensionsResponse {
78
+ string status = 1;
79
+ uint64 revision = 2;
80
+ }
81
+
82
+ message DecideExtensionTrustRequest {
83
+ string subject = 1;
84
+ optional string extension_id = 2;
85
+ string decision = 3;
86
+ repeated string granted_permissions = 4;
87
+ }
88
+
89
+ message DecideExtensionTrustResponse {
90
+ bool accepted = 1;
91
+ ReloadExtensionsResponse reload = 2;
92
+ }
93
+
94
+ service ExtensionService {
95
+ rpc GetExtensions(Empty) returns (ExtensionSnapshot);
96
+ rpc InvokeCommand(InvokeExtensionCommandRequest) returns (ExtensionCommandOutcome);
97
+ rpc Reload(ReloadExtensionsRequest) returns (ReloadExtensionsResponse);
98
+ rpc DecideTrust(DecideExtensionTrustRequest) returns (DecideExtensionTrustResponse);
99
+ }
@@ -0,0 +1,236 @@
1
+ // Graph engine domain: DAG/goal run state, subagent jobs, node output,
2
+ // control, checkpoint/restore, run enumeration, and the GraphEngineService
3
+ // RPC surface. Planning is agent-side; this surface observes and steers runs
4
+ // created by the dag_plan / goal tools.
5
+
6
+ syntax = "proto3";
7
+ package theway.grpc.v1;
8
+
9
+ import "commands.proto";
10
+
11
+ message DagRunSnapshot {
12
+ string id = 1;
13
+ string name = 2;
14
+ string status = 3; // running/completed/failed/cancelled
15
+ bool fail_fast = 4;
16
+ uint32 max_concurrency = 5;
17
+ string direction = 6; // TD/LR
18
+ int64 created_at = 7;
19
+ optional int64 completed_at = 8;
20
+ optional string error = 9;
21
+ repeated DagNodeSnapshot nodes = 10;
22
+ string kind = 11; // "dag" | "goal" — goal runs are single-node self-loops (condition-terminated)
23
+ }
24
+
25
+ message DagNodeSnapshot {
26
+ string id = 1;
27
+ string agent = 2;
28
+ string status = 3; // pending/ready/running/succeeded/failed/skipped/cancelled
29
+ repeated string depends_on = 4;
30
+ optional string job_id = 5; // ↔ SubagentJobSnapshot.id
31
+ uint32 attempt = 6;
32
+ optional int64 started_at = 7;
33
+ optional int64 completed_at = 8;
34
+ optional string error = 9;
35
+ optional uint64 input_tokens = 10;
36
+ optional uint64 output_tokens = 11;
37
+ optional NodeResultSnapshot result = 12;
38
+ optional string output_tail = 13; // terminal output tail; full text via events/GetNodeOutput
39
+ optional string live_preview = 14; // live output while running
40
+ }
41
+
42
+ message NodeResultSnapshot {
43
+ bool success = 1;
44
+ optional string error = 2;
45
+ optional uint64 duration_ms = 3;
46
+ uint32 attempt = 4;
47
+ uint32 total_attempts = 5;
48
+ }
49
+
50
+ message SubagentJobSnapshot {
51
+ string id = 1;
52
+ string agent = 2; // general / explorer / executor-coder / ...
53
+ string source = 3; // task | dag
54
+ optional string run_id = 4;
55
+ optional string node_id = 5;
56
+ string status = 6; // running/succeeded/failed/cancelled
57
+ optional int64 started_at = 7;
58
+ optional int64 completed_at = 8;
59
+ optional uint64 duration_ms = 9;
60
+ uint32 attempt = 10;
61
+ uint32 total_attempts = 11;
62
+ optional uint64 input_tokens = 12;
63
+ optional uint64 output_tokens = 13;
64
+ optional string error = 14;
65
+ optional string output_tail = 15;
66
+ optional string live_preview = 16;
67
+ // graph mode metrics:
68
+ optional double tps = 17; // output tokens/sec (sliding window)
69
+ optional double cps = 18; // output chars/sec
70
+ optional uint64 chars = 19; // cumulative output chars
71
+ optional uint64 tools_called = 20; // cumulative tool calls
72
+ optional uint32 turn = 21; // completed turns
73
+ }
74
+
75
+ // Full output of a DAG node, fetched on demand with an offset (P3).
76
+ message GetNodeOutputRequest {
77
+ string run_id = 1;
78
+ string node_id = 2;
79
+ uint64 offset = 3;
80
+ string session_id = 4;
81
+ }
82
+
83
+ message GetNodeOutputResponse {
84
+ string text = 1; // fragment from offset
85
+ uint64 offset = 2; // start offset of this fragment
86
+ uint64 total = 3; // full length
87
+ bool truncated = 4; // server buffer capped
88
+ // Full conversation transcript (user prompts + assistant turns with tool
89
+ // calls + tool results) as a JSON array of serde_json::Value — the same
90
+ // shape the registry keeps in memory and on disk. "" when unavailable
91
+ // (e.g. unknown node). Optional so older clients keep working.
92
+ optional string messages_json = 5;
93
+ bool messages_truncated = 6; // transcript buffer was capped (oldest dropped)
94
+ }
95
+
96
+ enum GraphKind {
97
+ GRAPH_DAG = 0;
98
+ GRAPH_GOAL = 1;
99
+ }
100
+
101
+ message GraphCancelRequest {
102
+ string run_id = 1;
103
+ string session_id = 2;
104
+ }
105
+
106
+ message GraphRetryRequest {
107
+ string run_id = 1;
108
+ optional string node_id = 2; // omitted = all failed/cancelled nodes
109
+ string session_id = 3;
110
+ }
111
+
112
+ message GraphRetryResponse {
113
+ repeated string reset_node_ids = 1;
114
+ }
115
+
116
+ message GraphSkipRequest {
117
+ string run_id = 1;
118
+ string node_id = 2;
119
+ string session_id = 3;
120
+ }
121
+
122
+ // Turn-level control for a running DAG node's subagent.
123
+ message GraphNodeInterruptRequest {
124
+ string run_id = 1;
125
+ string node_id = 2;
126
+ string session_id = 3;
127
+ }
128
+
129
+ message GraphNodeSteerRequest {
130
+ string run_id = 1;
131
+ string node_id = 2;
132
+ string text = 3;
133
+ string session_id = 4;
134
+ }
135
+
136
+ message GraphSkipResponse {
137
+ bool skipped = 1;
138
+ }
139
+
140
+ // Checkpoints are organized by session: a session owns its runs
141
+ // (DagRun.session_id), and `SessionSnapshot.graph_state.dags` mounts the live graph status
142
+ // under that session. Checkpoint exports one run or the session's whole graph
143
+ // set as portable JSON snapshots; restore revives them back under the session.
144
+ message GraphCheckpointRequest {
145
+ // Owning session. Omitted = the session this connection belongs to.
146
+ optional string session_id = 1;
147
+ // Omitted = every running run of the session; set to export a single run.
148
+ optional string run_id = 2;
149
+ }
150
+
151
+ message GraphCheckpointResponse {
152
+ string session_id = 1;
153
+ repeated GraphSnapshotEntry checkpoints = 2;
154
+ optional string error = 3;
155
+ }
156
+
157
+ message GraphSnapshotEntry {
158
+ GraphKind kind = 1;
159
+ string run_id = 2;
160
+ string snapshot = 3; // JSON (PersistedRun shape: definition, node states, progress)
161
+ }
162
+
163
+ // Restore: resume run(s) from GraphCheckpoint snapshots. Running runs are
164
+ // revived with their ready nodes re-scheduled, and re-attached to the session.
165
+ message GraphRestoreRequest {
166
+ string session_id = 1;
167
+ string snapshot = 2; // single GraphSnapshotEntry.snapshot (PersistedRun JSON)
168
+ }
169
+
170
+ message GraphRestoreResponse {
171
+ string run_id = 1;
172
+ optional string error = 2;
173
+ }
174
+
175
+ message GraphListRequest {
176
+ string session_id = 1;
177
+ }
178
+
179
+ message GraphListResponse {
180
+ repeated DagRunSnapshot runs = 1;
181
+ }
182
+
183
+ // Node type in a session graph.
184
+ enum SessionGraphNodeType {
185
+ SESSION_GRAPH_NODE_TYPE_UNSPECIFIED = 0;
186
+ SESSION_GRAPH_NODE_TYPE_SESSION = 1;
187
+ SESSION_GRAPH_NODE_TYPE_COLLAPSED = 2;
188
+ }
189
+
190
+ // A node in the session graph. Session nodes represent live sessions;
191
+ // collapsed nodes represent archived sessions folded into another session.
192
+ message SessionGraphNode {
193
+ string id = 1;
194
+ string session_id = 2;
195
+ SessionGraphNodeType type = 3;
196
+ string title = 4;
197
+ string summary = 5;
198
+ optional string parent_node_id = 6;
199
+ repeated string child_node_ids = 7;
200
+ optional string collapsed_session_id = 8;
201
+ optional string collapsed_at = 9; // RFC3339 / ISO-8601 with offset (UTC).
202
+ optional string created_at = 10;
203
+ optional string updated_at = 11;
204
+ uint32 message_count = 12;
205
+ }
206
+
207
+ // Detailed record for a session that has been collapsed into another session.
208
+ message CollapsedSessionNode {
209
+ string node_id = 1;
210
+ string session_id = 2;
211
+ string title = 3;
212
+ string summary = 4;
213
+ uint32 message_count = 5;
214
+ optional string collapsed_at = 6; // RFC3339 / ISO-8601 with offset (UTC).
215
+ optional string collapsed_into_session_id = 7;
216
+ optional string collapsed_into_node_id = 8;
217
+ repeated string original_session_ids = 9;
218
+ }
219
+
220
+ service GraphEngineService {
221
+ // Fetch a DAG node's full output from an offset (P3).
222
+ rpc GetNodeOutput(GetNodeOutputRequest) returns (GetNodeOutputResponse);
223
+ // Graph orchestration control (DAG + goal runs; planning is agent-side).
224
+ rpc GraphCancel(GraphCancelRequest) returns (CommandResult);
225
+ rpc GraphRetry(GraphRetryRequest) returns (GraphRetryResponse);
226
+ rpc GraphSkip(GraphSkipRequest) returns (GraphSkipResponse);
227
+ // Stop the node's in-flight turn (run ends unless steering was queued).
228
+ rpc GraphNodeInterrupt(GraphNodeInterruptRequest) returns (CommandResult);
229
+ // Queue a steering message injected at the node's next natural turn boundary.
230
+ rpc GraphNodeSteer(GraphNodeSteerRequest) returns (CommandResult);
231
+ // Checkpoint / restore (portable run snapshots for external persistence).
232
+ rpc GraphCheckpoint(GraphCheckpointRequest) returns (GraphCheckpointResponse);
233
+ rpc GraphRestore(GraphRestoreRequest) returns (GraphRestoreResponse);
234
+ // Enumerate one session's graph runs (DagRunSnapshot shape).
235
+ rpc GraphList(GraphListRequest) returns (GraphListResponse);
236
+ }
@@ -0,0 +1,26 @@
1
+ // Standard gRPC health checking protocol (grpc.health.v1), hand-written
2
+ // equivalent of grpc/grpc's health.proto. Served alongside theway.grpc.v1 so
3
+ // generic health probes (grpc_health_probe, load balancers, k8s-style checks)
4
+ // work without importing the domain proto. See docs/PROTOCOL.md.
5
+
6
+ syntax = "proto3";
7
+ package grpc.health.v1;
8
+
9
+ message HealthCheckRequest {
10
+ string service = 1;
11
+ }
12
+
13
+ message HealthCheckResponse {
14
+ enum ServingStatus {
15
+ UNKNOWN = 0;
16
+ SERVING = 1;
17
+ NOT_SERVING = 2;
18
+ SERVICE_UNKNOWN = 3;
19
+ }
20
+ ServingStatus status = 1;
21
+ }
22
+
23
+ service Health {
24
+ rpc Check(HealthCheckRequest) returns (HealthCheckResponse);
25
+ rpc Watch(HealthCheckRequest) returns (stream HealthCheckResponse);
26
+ }