@sw4rm/js-sdk 0.4.0 → 0.6.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.
- package/README.md +178 -1
- package/dist/cjs/index.cjs +2819 -292
- package/dist/esm/index.js +2736 -284
- package/dist/types/agentConfig.d.ts +245 -0
- package/dist/types/audit.d.ts +214 -0
- package/dist/types/clients/handoff.d.ts +44 -1
- package/dist/types/clients/negotiationRoom.d.ts +81 -5
- package/dist/types/clients/negotiationRoomStore.d.ts +155 -0
- package/dist/types/clients/workflow.d.ts +15 -0
- package/dist/types/constants/index.d.ts +100 -0
- package/dist/types/index.d.ts +14 -5
- package/dist/types/internal/baseClient.d.ts +6 -0
- package/dist/types/internal/envelope.d.ts +16 -0
- package/dist/types/internal/errorMapping.d.ts +116 -0
- package/dist/types/internal/worktreeState.d.ts +60 -0
- package/dist/types/llm/anthropic.d.ts +83 -0
- package/dist/types/llm/client.d.ts +107 -0
- package/dist/types/llm/factory.d.ts +69 -0
- package/dist/types/llm/groq.d.ts +79 -0
- package/dist/types/llm/index.d.ts +45 -0
- package/dist/types/llm/mock.d.ts +89 -0
- package/dist/types/llm/rateLimiter.d.ts +101 -0
- package/dist/types/persistentActivityBuffer.d.ts +94 -0
- package/dist/types/runtime/cancellation.d.ts +41 -0
- package/dist/types/runtime/delegation.d.ts +20 -0
- package/dist/types/runtime/gateway.d.ts +80 -0
- package/package.json +4 -2
- package/protos/activity.proto +24 -0
- package/protos/common.proto +141 -0
- package/protos/connector.proto +29 -0
- package/protos/handoff.proto +105 -0
- package/protos/hitl.proto +23 -0
- package/protos/logging.proto +20 -0
- package/protos/negotiation.proto +57 -0
- package/protos/negotiation_room.proto +220 -0
- package/protos/policy.proto +55 -0
- package/protos/reasoning.proto +41 -0
- package/protos/registry.proto +47 -0
- package/protos/router.proto +16 -0
- package/protos/scheduler.proto +52 -0
- package/protos/scheduler_policy.proto +36 -0
- package/protos/tool.proto +47 -0
- package/protos/workflow.proto +116 -0
- package/protos/worktree.proto +33 -0
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
// SW4RM Protocol - Negotiation Room Proto Definition
|
|
2
|
+
// Namespace Convention: sw4rm.{service} (e.g., sw4rm.negotiation_room)
|
|
3
|
+
// See: docs/IMPLEMENTATION_PLAN.md Phase 1.1 for namespace standards.
|
|
4
|
+
|
|
5
|
+
syntax = "proto3";
|
|
6
|
+
|
|
7
|
+
package sw4rm.negotiation_room;
|
|
8
|
+
|
|
9
|
+
import "google/protobuf/timestamp.proto";
|
|
10
|
+
|
|
11
|
+
// ArtifactType enum represents the category of artifact being negotiated
|
|
12
|
+
// Maps to different stages of the workflow process
|
|
13
|
+
enum ArtifactType {
|
|
14
|
+
ARTIFACT_TYPE_UNSPECIFIED = 0;
|
|
15
|
+
REQUIREMENTS = 1;
|
|
16
|
+
PLAN = 2;
|
|
17
|
+
CODE = 3;
|
|
18
|
+
DEPLOYMENT = 4;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// DecisionOutcome enum represents the final decision made by the coordinator
|
|
22
|
+
// after aggregating critic votes and applying policy
|
|
23
|
+
enum DecisionOutcome {
|
|
24
|
+
DECISION_OUTCOME_UNSPECIFIED = 0;
|
|
25
|
+
APPROVED = 1;
|
|
26
|
+
REVISION_REQUESTED = 2;
|
|
27
|
+
ESCALATED_TO_HITL = 3;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// NegotiationProposal represents a proposal for artifact evaluation in a negotiation room.
|
|
31
|
+
// Submitted by a producer agent to request multi-agent review of an artifact.
|
|
32
|
+
message NegotiationProposal {
|
|
33
|
+
// Category of artifact (requirements, plan, code, deployment)
|
|
34
|
+
ArtifactType artifact_type = 1;
|
|
35
|
+
|
|
36
|
+
// Unique identifier for this artifact
|
|
37
|
+
string artifact_id = 2;
|
|
38
|
+
|
|
39
|
+
// Agent ID of the producer submitting the artifact
|
|
40
|
+
string producer_id = 3;
|
|
41
|
+
|
|
42
|
+
// Binary artifact content (e.g., serialized JSON, code files)
|
|
43
|
+
bytes artifact = 4;
|
|
44
|
+
|
|
45
|
+
// MIME type or content type identifier
|
|
46
|
+
string artifact_content_type = 5;
|
|
47
|
+
|
|
48
|
+
// List of critic agent IDs requested for evaluation
|
|
49
|
+
repeated string requested_critics = 6;
|
|
50
|
+
|
|
51
|
+
// Identifier for the negotiation room session
|
|
52
|
+
string negotiation_room_id = 7;
|
|
53
|
+
|
|
54
|
+
// Timestamp when proposal was created
|
|
55
|
+
google.protobuf.Timestamp created_at = 8;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// NegotiationVote represents a critic's evaluation of an artifact.
|
|
59
|
+
// Represents a single critic's assessment including numerical scoring,
|
|
60
|
+
// qualitative feedback, and confidence level based on POMDP uncertainty.
|
|
61
|
+
message NegotiationVote {
|
|
62
|
+
// Identifier of the artifact being evaluated
|
|
63
|
+
string artifact_id = 1;
|
|
64
|
+
|
|
65
|
+
// Agent ID of the critic providing this vote
|
|
66
|
+
string critic_id = 2;
|
|
67
|
+
|
|
68
|
+
// Numerical score from 0-10 (10 = excellent)
|
|
69
|
+
double score = 3;
|
|
70
|
+
|
|
71
|
+
// Confidence level from 0-1 (based on POMDP research)
|
|
72
|
+
double confidence = 4;
|
|
73
|
+
|
|
74
|
+
// Boolean indicating if artifact meets minimum criteria
|
|
75
|
+
bool passed = 5;
|
|
76
|
+
|
|
77
|
+
// List of identified strengths in the artifact
|
|
78
|
+
repeated string strengths = 6;
|
|
79
|
+
|
|
80
|
+
// List of identified weaknesses or concerns
|
|
81
|
+
repeated string weaknesses = 7;
|
|
82
|
+
|
|
83
|
+
// List of suggestions for improvement
|
|
84
|
+
repeated string recommendations = 8;
|
|
85
|
+
|
|
86
|
+
// Identifier for the negotiation room session
|
|
87
|
+
string negotiation_room_id = 9;
|
|
88
|
+
|
|
89
|
+
// Timestamp when vote was cast
|
|
90
|
+
google.protobuf.Timestamp voted_at = 10;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// AggregatedScore provides statistical aggregation of multiple critic votes.
|
|
94
|
+
// Provides multiple views of the voting results including basic statistics
|
|
95
|
+
// and confidence-weighted metrics for decision making.
|
|
96
|
+
message AggregatedScore {
|
|
97
|
+
// Arithmetic mean of all scores
|
|
98
|
+
double mean = 1;
|
|
99
|
+
|
|
100
|
+
// Minimum score from any critic
|
|
101
|
+
double min_score = 2;
|
|
102
|
+
|
|
103
|
+
// Maximum score from any critic
|
|
104
|
+
double max_score = 3;
|
|
105
|
+
|
|
106
|
+
// Standard deviation of scores (measures consensus)
|
|
107
|
+
double std_dev = 4;
|
|
108
|
+
|
|
109
|
+
// Confidence-weighted mean (higher confidence votes weighted more)
|
|
110
|
+
double weighted_mean = 5;
|
|
111
|
+
|
|
112
|
+
// Number of votes included in aggregation
|
|
113
|
+
int32 vote_count = 6;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// NegotiationDecision represents the final decision on an artifact after critic evaluation.
|
|
117
|
+
// Represents the coordinator's decision after aggregating all critic votes
|
|
118
|
+
// and applying policy thresholds. Includes full audit trail of votes and reasoning.
|
|
119
|
+
message NegotiationDecision {
|
|
120
|
+
// Identifier of the artifact that was evaluated
|
|
121
|
+
string artifact_id = 1;
|
|
122
|
+
|
|
123
|
+
// Final decision (approved, revision requested, escalated to HITL)
|
|
124
|
+
DecisionOutcome outcome = 2;
|
|
125
|
+
|
|
126
|
+
// Complete list of all critic votes considered
|
|
127
|
+
repeated NegotiationVote votes = 3;
|
|
128
|
+
|
|
129
|
+
// Statistical summary of the votes
|
|
130
|
+
AggregatedScore aggregated_score = 4;
|
|
131
|
+
|
|
132
|
+
// Version identifier of the policy used for decision
|
|
133
|
+
string policy_version = 5;
|
|
134
|
+
|
|
135
|
+
// Human-readable explanation of the decision
|
|
136
|
+
string reason = 6;
|
|
137
|
+
|
|
138
|
+
// Identifier for the negotiation room session
|
|
139
|
+
string negotiation_room_id = 7;
|
|
140
|
+
|
|
141
|
+
// Timestamp when decision was made
|
|
142
|
+
google.protobuf.Timestamp decided_at = 8;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// Request to submit a proposal to the negotiation room
|
|
146
|
+
message SubmitProposalRequest {
|
|
147
|
+
NegotiationProposal proposal = 1;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// Response after submitting a proposal
|
|
151
|
+
message SubmitProposalResponse {
|
|
152
|
+
string artifact_id = 1;
|
|
153
|
+
string negotiation_room_id = 2;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// Request to submit a vote for an artifact
|
|
157
|
+
message SubmitVoteRequest {
|
|
158
|
+
NegotiationVote vote = 1;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// Response after submitting a vote
|
|
162
|
+
message SubmitVoteResponse {
|
|
163
|
+
string artifact_id = 1;
|
|
164
|
+
string critic_id = 2;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// Request to get all votes for an artifact
|
|
168
|
+
message GetVotesRequest {
|
|
169
|
+
string artifact_id = 1;
|
|
170
|
+
string negotiation_room_id = 2;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// Response containing all votes for an artifact
|
|
174
|
+
message GetVotesResponse {
|
|
175
|
+
repeated NegotiationVote votes = 1;
|
|
176
|
+
int32 vote_count = 2;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// Request to get the decision for an artifact
|
|
180
|
+
message GetDecisionRequest {
|
|
181
|
+
string artifact_id = 1;
|
|
182
|
+
string negotiation_room_id = 2;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// Response containing the decision for an artifact
|
|
186
|
+
message GetDecisionResponse {
|
|
187
|
+
NegotiationDecision decision = 1;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// Request to wait for a decision (blocking call)
|
|
191
|
+
message WaitForDecisionRequest {
|
|
192
|
+
string artifact_id = 1;
|
|
193
|
+
string negotiation_room_id = 2;
|
|
194
|
+
// Optional timeout in seconds
|
|
195
|
+
uint32 timeout_seconds = 3;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// Response for waiting on a decision
|
|
199
|
+
message WaitForDecisionResponse {
|
|
200
|
+
NegotiationDecision decision = 1;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// NegotiationRoomService provides RPC endpoints for the Negotiation Room pattern
|
|
204
|
+
// enabling multi-agent artifact approval workflows
|
|
205
|
+
service NegotiationRoomService {
|
|
206
|
+
// SubmitProposal allows a producer agent to submit an artifact for review
|
|
207
|
+
rpc SubmitProposal(SubmitProposalRequest) returns (SubmitProposalResponse);
|
|
208
|
+
|
|
209
|
+
// SubmitVote allows a critic agent to submit their evaluation of an artifact
|
|
210
|
+
rpc SubmitVote(SubmitVoteRequest) returns (SubmitVoteResponse);
|
|
211
|
+
|
|
212
|
+
// GetVotes retrieves all votes submitted for a specific artifact
|
|
213
|
+
rpc GetVotes(GetVotesRequest) returns (GetVotesResponse);
|
|
214
|
+
|
|
215
|
+
// GetDecision retrieves the final decision for an artifact (non-blocking)
|
|
216
|
+
rpc GetDecision(GetDecisionRequest) returns (GetDecisionResponse);
|
|
217
|
+
|
|
218
|
+
// WaitForDecision blocks until a decision is made for an artifact
|
|
219
|
+
rpc WaitForDecision(WaitForDecisionRequest) returns (WaitForDecisionResponse);
|
|
220
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
|
|
3
|
+
package sw4rm.policy;
|
|
4
|
+
|
|
5
|
+
message NegotiationPolicy {
|
|
6
|
+
uint32 max_rounds = 1;
|
|
7
|
+
float score_threshold = 2; // 0..1
|
|
8
|
+
float diff_tolerance = 3; // 0..1
|
|
9
|
+
uint64 round_timeout_ms = 4;
|
|
10
|
+
uint64 token_budget_per_round = 5;
|
|
11
|
+
uint64 total_token_budget = 6; // optional 0=unset
|
|
12
|
+
uint32 oscillation_limit = 7;
|
|
13
|
+
message Hitl { string mode = 1; } // None|PauseBetweenRounds|PauseOnFinalAccept
|
|
14
|
+
Hitl hitl = 8;
|
|
15
|
+
message Scoring { bool require_schema_valid = 1; bool require_examples_pass = 2; float llm_weight = 3; }
|
|
16
|
+
Scoring scoring = 9;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
message AgentPreferences {
|
|
20
|
+
// Same fields as NegotiationPolicy but advisory; scheduler clamps to guardrails
|
|
21
|
+
uint32 max_rounds = 1;
|
|
22
|
+
float score_threshold = 2;
|
|
23
|
+
float diff_tolerance = 3;
|
|
24
|
+
uint64 round_timeout_ms = 4;
|
|
25
|
+
uint64 token_budget_per_round = 5;
|
|
26
|
+
uint64 total_token_budget = 6;
|
|
27
|
+
uint32 oscillation_limit = 7;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
message EffectivePolicy {
|
|
31
|
+
NegotiationPolicy policy = 1; // derived authoritative policy
|
|
32
|
+
map<string, AgentPreferences> applied = 2; // per-agent clamped prefs (optional)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
message PolicyProfile {
|
|
36
|
+
string name = 1; // e.g., LOW/MEDIUM/HIGH
|
|
37
|
+
NegotiationPolicy policy = 2;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
message DeltaSummary { float magnitude = 1; repeated string changed_paths = 2; }
|
|
41
|
+
|
|
42
|
+
message EvaluationReport {
|
|
43
|
+
string from_agent = 1;
|
|
44
|
+
float deterministic_score = 2; // 0..1
|
|
45
|
+
float llm_confidence = 3; // 0..1, optional 0 if absent
|
|
46
|
+
string notes = 4;
|
|
47
|
+
DeltaSummary delta = 5;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
message DecisionReport {
|
|
51
|
+
string decided_by = 1; // consensus|hitl|policy
|
|
52
|
+
float final_score = 2;
|
|
53
|
+
string rationale = 3;
|
|
54
|
+
string stop_reason = 4; // threshold_met|max_rounds|oscillation|budget|timeout
|
|
55
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
|
|
3
|
+
package sw4rm.reasoning;
|
|
4
|
+
|
|
5
|
+
message ParallelismCheckRequest { string scope_a = 1; string scope_b = 2; }
|
|
6
|
+
message ParallelismCheckResponse { double confidence_score = 1; string notes = 2; }
|
|
7
|
+
|
|
8
|
+
message DebateEvaluateRequest {
|
|
9
|
+
string negotiation_id = 1;
|
|
10
|
+
string proposal_a = 2;
|
|
11
|
+
string proposal_b = 3;
|
|
12
|
+
string intensity = 4; // map from enum if needed
|
|
13
|
+
}
|
|
14
|
+
message DebateEvaluateResponse { double confidence_score = 1; string notes = 2; }
|
|
15
|
+
|
|
16
|
+
service ReasoningProxy {
|
|
17
|
+
rpc CheckParallelism(ParallelismCheckRequest) returns (ParallelismCheckResponse);
|
|
18
|
+
rpc EvaluateDebate(DebateEvaluateRequest) returns (DebateEvaluateResponse);
|
|
19
|
+
rpc Summarize(SummarizeRequest) returns (SummarizeResponse);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
message TextSegment {
|
|
23
|
+
string kind = 1;
|
|
24
|
+
string content = 2;
|
|
25
|
+
int64 seq = 3;
|
|
26
|
+
string at = 4;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
message SummarizeRequest {
|
|
30
|
+
string session_id = 1;
|
|
31
|
+
repeated TextSegment segments = 2;
|
|
32
|
+
uint32 max_tokens = 3;
|
|
33
|
+
string mode = 4;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
message SummarizeResponse {
|
|
37
|
+
string summary = 1;
|
|
38
|
+
uint32 tokens = 2;
|
|
39
|
+
double cost_cents = 3;
|
|
40
|
+
string model = 4;
|
|
41
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
|
|
3
|
+
package sw4rm.registry;
|
|
4
|
+
|
|
5
|
+
import "google/protobuf/timestamp.proto";
|
|
6
|
+
import "common.proto";
|
|
7
|
+
|
|
8
|
+
// SW4-004 Inter-Swarm Composition
|
|
9
|
+
enum RegistrationType {
|
|
10
|
+
REGISTRATION_TYPE_UNSPECIFIED = 0;
|
|
11
|
+
STANDARD_AGENT = 1;
|
|
12
|
+
SWARM_GATEWAY = 2;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
message AgentDescriptor {
|
|
16
|
+
string agent_id = 1;
|
|
17
|
+
string name = 2;
|
|
18
|
+
string description = 3; // ≤200 words
|
|
19
|
+
repeated string capabilities = 4;
|
|
20
|
+
sw4rm.common.CommunicationClass communication_class = 5;
|
|
21
|
+
repeated string modalities_supported = 6; // MIME types
|
|
22
|
+
repeated string reasoning_connectors = 7; // URIs
|
|
23
|
+
bytes public_key = 8; // optional
|
|
24
|
+
|
|
25
|
+
// SW4-004 Inter-Swarm Composition (fields 100-109)
|
|
26
|
+
RegistrationType registration_type = 100; // default STANDARD_AGENT
|
|
27
|
+
uint32 max_concurrent_delegations = 101; // normative for SWARM_GATEWAY, advisory for STANDARD_AGENT
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
message RegisterAgentRequest { AgentDescriptor agent = 1; }
|
|
31
|
+
message RegisterAgentResponse { bool accepted = 1; string reason = 2; }
|
|
32
|
+
|
|
33
|
+
message HeartbeatRequest {
|
|
34
|
+
string agent_id = 1;
|
|
35
|
+
sw4rm.common.AgentState state = 2;
|
|
36
|
+
map<string,string> health = 3;
|
|
37
|
+
}
|
|
38
|
+
message HeartbeatResponse { bool ok = 1; }
|
|
39
|
+
|
|
40
|
+
message DeregisterAgentRequest { string agent_id = 1; string reason = 2; }
|
|
41
|
+
message DeregisterAgentResponse { bool ok = 1; }
|
|
42
|
+
|
|
43
|
+
service RegistryService {
|
|
44
|
+
rpc RegisterAgent(RegisterAgentRequest) returns (RegisterAgentResponse);
|
|
45
|
+
rpc Heartbeat(HeartbeatRequest) returns (HeartbeatResponse);
|
|
46
|
+
rpc DeregisterAgent(DeregisterAgentRequest) returns (DeregisterAgentResponse);
|
|
47
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
|
|
3
|
+
package sw4rm.router;
|
|
4
|
+
|
|
5
|
+
import "common.proto";
|
|
6
|
+
|
|
7
|
+
message SendMessageRequest { sw4rm.common.Envelope msg = 1; }
|
|
8
|
+
message SendMessageResponse { bool accepted = 1; string reason = 2; }
|
|
9
|
+
|
|
10
|
+
message StreamRequest { string agent_id = 1; }
|
|
11
|
+
message StreamItem { sw4rm.common.Envelope msg = 1; }
|
|
12
|
+
|
|
13
|
+
service RouterService {
|
|
14
|
+
rpc SendMessage(SendMessageRequest) returns (SendMessageResponse);
|
|
15
|
+
rpc StreamIncoming(StreamRequest) returns (stream StreamItem); // per-agent inbound stream
|
|
16
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
|
|
3
|
+
package sw4rm.scheduler;
|
|
4
|
+
|
|
5
|
+
import "google/protobuf/duration.proto";
|
|
6
|
+
import "common.proto";
|
|
7
|
+
|
|
8
|
+
message SubmitTaskRequest {
|
|
9
|
+
string agent_id = 1;
|
|
10
|
+
string task_id = 2;
|
|
11
|
+
int32 priority = 3; // -19..20
|
|
12
|
+
bytes params = 4;
|
|
13
|
+
string content_type = 5;
|
|
14
|
+
string scope = 6; // resource scope descriptor
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
message SubmitTaskResponse { bool accepted = 1; string reason = 2; }
|
|
18
|
+
|
|
19
|
+
message PreemptRequest {
|
|
20
|
+
string agent_id = 1;
|
|
21
|
+
string task_id = 2;
|
|
22
|
+
string reason = 3;
|
|
23
|
+
}
|
|
24
|
+
message PreemptResponse { bool enqueued = 1; }
|
|
25
|
+
|
|
26
|
+
message ShutdownAgentRequest {
|
|
27
|
+
string agent_id = 1;
|
|
28
|
+
google.protobuf.Duration grace_period = 2;
|
|
29
|
+
}
|
|
30
|
+
message ShutdownAgentResponse { bool ok = 1; }
|
|
31
|
+
|
|
32
|
+
message PollActivityBufferRequest { string agent_id = 1; }
|
|
33
|
+
message ActivityEntry {
|
|
34
|
+
string task_id = 1;
|
|
35
|
+
string repo_id = 2;
|
|
36
|
+
string worktree_id = 3;
|
|
37
|
+
string branch = 4;
|
|
38
|
+
string description = 5;
|
|
39
|
+
string timestamp = 6;
|
|
40
|
+
}
|
|
41
|
+
message PollActivityBufferResponse { repeated ActivityEntry entries = 1; }
|
|
42
|
+
|
|
43
|
+
message PurgeActivityRequest { string agent_id = 1; repeated string task_ids = 2; }
|
|
44
|
+
message PurgeActivityResponse { uint32 purged = 1; }
|
|
45
|
+
|
|
46
|
+
service SchedulerService {
|
|
47
|
+
rpc SubmitTask(SubmitTaskRequest) returns (SubmitTaskResponse);
|
|
48
|
+
rpc RequestPreemption(PreemptRequest) returns (PreemptResponse);
|
|
49
|
+
rpc ShutdownAgent(ShutdownAgentRequest) returns (ShutdownAgentResponse);
|
|
50
|
+
rpc PollActivityBuffer(PollActivityBufferRequest) returns (PollActivityBufferResponse);
|
|
51
|
+
rpc PurgeActivity(PurgeActivityRequest) returns (PurgeActivityResponse);
|
|
52
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
|
|
3
|
+
package sw4rm.scheduler;
|
|
4
|
+
|
|
5
|
+
import "policy.proto";
|
|
6
|
+
|
|
7
|
+
message SetNegotiationPolicyRequest { sw4rm.policy.NegotiationPolicy policy = 1; }
|
|
8
|
+
message SetNegotiationPolicyResponse { bool ok = 1; string reason = 2; }
|
|
9
|
+
|
|
10
|
+
message GetNegotiationPolicyRequest {}
|
|
11
|
+
message GetNegotiationPolicyResponse { sw4rm.policy.NegotiationPolicy policy = 1; }
|
|
12
|
+
|
|
13
|
+
message SetPolicyProfilesRequest { repeated sw4rm.policy.PolicyProfile profiles = 1; }
|
|
14
|
+
message SetPolicyProfilesResponse { bool ok = 1; string reason = 2; }
|
|
15
|
+
|
|
16
|
+
message ListPolicyProfilesRequest {}
|
|
17
|
+
message ListPolicyProfilesResponse { repeated sw4rm.policy.PolicyProfile profiles = 1; }
|
|
18
|
+
|
|
19
|
+
message GetEffectivePolicyRequest { string negotiation_id = 1; }
|
|
20
|
+
message GetEffectivePolicyResponse { sw4rm.policy.EffectivePolicy effective = 1; }
|
|
21
|
+
|
|
22
|
+
message SubmitEvaluationRequest { string negotiation_id = 1; sw4rm.policy.EvaluationReport report = 2; }
|
|
23
|
+
message SubmitEvaluationResponse { bool accepted = 1; string reason = 2; }
|
|
24
|
+
|
|
25
|
+
message HitlActionRequest { string negotiation_id = 1; string action = 2; string rationale = 3; }
|
|
26
|
+
message HitlActionResponse { bool ok = 1; string reason = 2; }
|
|
27
|
+
|
|
28
|
+
service SchedulerPolicyService {
|
|
29
|
+
rpc SetNegotiationPolicy(SetNegotiationPolicyRequest) returns (SetNegotiationPolicyResponse);
|
|
30
|
+
rpc GetNegotiationPolicy(GetNegotiationPolicyRequest) returns (GetNegotiationPolicyResponse);
|
|
31
|
+
rpc SetPolicyProfiles(SetPolicyProfilesRequest) returns (SetPolicyProfilesResponse);
|
|
32
|
+
rpc ListPolicyProfiles(ListPolicyProfilesRequest) returns (ListPolicyProfilesResponse);
|
|
33
|
+
rpc GetEffectivePolicy(GetEffectivePolicyRequest) returns (GetEffectivePolicyResponse);
|
|
34
|
+
rpc SubmitEvaluation(SubmitEvaluationRequest) returns (SubmitEvaluationResponse);
|
|
35
|
+
rpc HitlAction(HitlActionRequest) returns (HitlActionResponse);
|
|
36
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
|
|
3
|
+
package sw4rm.tool;
|
|
4
|
+
|
|
5
|
+
import "google/protobuf/duration.proto";
|
|
6
|
+
|
|
7
|
+
message ExecutionPolicy {
|
|
8
|
+
google.protobuf.Duration timeout = 1;
|
|
9
|
+
uint32 max_retries = 2;
|
|
10
|
+
string backoff = 3; // "exponential", etc.
|
|
11
|
+
bool worktree_required = 4;
|
|
12
|
+
string network_policy = 5; // e.g., "egress_restricted"
|
|
13
|
+
string privilege_level = 6; // e.g., "default"
|
|
14
|
+
uint64 budget_cpu_ms = 7;
|
|
15
|
+
uint64 budget_wall_ms = 8;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
message ToolCall {
|
|
19
|
+
string call_id = 1;
|
|
20
|
+
string tool_name = 2;
|
|
21
|
+
string provider_id = 3;
|
|
22
|
+
string content_type = 4;
|
|
23
|
+
bytes args = 5;
|
|
24
|
+
ExecutionPolicy policy = 6;
|
|
25
|
+
bool stream = 7;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
message ToolFrame {
|
|
29
|
+
string call_id = 1;
|
|
30
|
+
uint64 frame_no = 2;
|
|
31
|
+
bool final = 3;
|
|
32
|
+
string content_type = 4;
|
|
33
|
+
bytes data = 5;
|
|
34
|
+
bytes summary = 6; // optional final summary
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
message ToolError {
|
|
38
|
+
string call_id = 1;
|
|
39
|
+
string error_code = 2;
|
|
40
|
+
string message = 3;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
service ToolService {
|
|
44
|
+
rpc Call(ToolCall) returns (ToolFrame); // unary completion
|
|
45
|
+
rpc CallStream(ToolCall) returns (stream ToolFrame); // streaming frames
|
|
46
|
+
rpc Cancel(ToolCall) returns (ToolError); // best effort
|
|
47
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
// SW4RM Protocol - Workflow Proto Definition
|
|
2
|
+
// Namespace Convention: sw4rm.{service} (e.g., sw4rm.workflow)
|
|
3
|
+
// See: docs/IMPLEMENTATION_PLAN.md Phase 1.1 for namespace standards.
|
|
4
|
+
|
|
5
|
+
syntax = "proto3";
|
|
6
|
+
|
|
7
|
+
package sw4rm.workflow;
|
|
8
|
+
|
|
9
|
+
import "google/protobuf/timestamp.proto";
|
|
10
|
+
|
|
11
|
+
enum NodeStatus {
|
|
12
|
+
NODE_STATUS_UNSPECIFIED = 0;
|
|
13
|
+
PENDING = 1; // Node waiting for dependencies
|
|
14
|
+
READY = 2; // Node ready to execute
|
|
15
|
+
RUNNING = 3; // Node currently executing
|
|
16
|
+
COMPLETED = 4; // Node finished successfully
|
|
17
|
+
FAILED = 5; // Node encountered an error
|
|
18
|
+
SKIPPED = 6; // Node skipped due to conditional logic
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
enum TriggerType {
|
|
22
|
+
TRIGGER_TYPE_UNSPECIFIED = 0;
|
|
23
|
+
EVENT = 1; // Triggered by specific events
|
|
24
|
+
SCHEDULE = 2; // Triggered on a schedule (cron-like)
|
|
25
|
+
MANUAL = 3; // Triggered by explicit user action
|
|
26
|
+
DEPENDENCY = 4; // Triggered by dependency completion
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
message WorkflowNode {
|
|
30
|
+
string node_id = 1; // Unique identifier for this node
|
|
31
|
+
string agent_id = 2; // Identifier of the agent executing this node
|
|
32
|
+
repeated string dependencies = 3; // Set of node_ids that must complete before this node runs
|
|
33
|
+
TriggerType trigger_type = 4; // How this node is triggered
|
|
34
|
+
map<string, string> input_mapping = 5; // Maps workflow state keys to node input parameters
|
|
35
|
+
map<string, string> output_mapping = 6; // Maps node output keys to workflow state keys
|
|
36
|
+
map<string, string> metadata = 7; // Additional node configuration and context
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
message WorkflowDefinition {
|
|
40
|
+
string workflow_id = 1; // Unique identifier for this workflow
|
|
41
|
+
map<string, WorkflowNode> nodes = 2; // Map of node_id to WorkflowNode
|
|
42
|
+
google.protobuf.Timestamp created_at = 3; // When the workflow was created
|
|
43
|
+
map<string, string> metadata = 4; // Additional workflow-level configuration
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
message NodeState {
|
|
47
|
+
string node_id = 1; // The node this state belongs to
|
|
48
|
+
NodeStatus status = 2; // Current execution status
|
|
49
|
+
google.protobuf.Timestamp started_at = 3; // When node execution started
|
|
50
|
+
google.protobuf.Timestamp completed_at = 4; // When node execution completed
|
|
51
|
+
string output = 5; // Output data from node execution (JSON string)
|
|
52
|
+
string error = 6; // Error information if node failed
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
message WorkflowState {
|
|
56
|
+
string workflow_id = 1; // Identifier of the workflow being executed
|
|
57
|
+
map<string, NodeState> node_states = 2; // Map of node_id to NodeState for tracking execution
|
|
58
|
+
string workflow_data = 3; // Shared workflow data (JSON string)
|
|
59
|
+
google.protobuf.Timestamp started_at = 4; // When the workflow execution started
|
|
60
|
+
google.protobuf.Timestamp completed_at = 5; // When the workflow execution completed
|
|
61
|
+
map<string, string> metadata = 6; // Additional runtime metadata
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
message CreateWorkflowRequest {
|
|
65
|
+
WorkflowDefinition definition = 1;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
message CreateWorkflowResponse {
|
|
69
|
+
string workflow_id = 1;
|
|
70
|
+
bool success = 2;
|
|
71
|
+
string error = 3;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
message StartWorkflowRequest {
|
|
75
|
+
string workflow_id = 1;
|
|
76
|
+
string workflow_data = 2; // Initial workflow data (JSON string)
|
|
77
|
+
map<string, string> metadata = 3; // Runtime metadata
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
message StartWorkflowResponse {
|
|
81
|
+
string workflow_id = 1;
|
|
82
|
+
WorkflowState state = 2;
|
|
83
|
+
bool success = 3;
|
|
84
|
+
string error = 4;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
message GetWorkflowStateRequest {
|
|
88
|
+
string workflow_id = 1;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
message GetWorkflowStateResponse {
|
|
92
|
+
WorkflowState state = 1;
|
|
93
|
+
bool success = 2;
|
|
94
|
+
string error = 3;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
message ResumeWorkflowRequest {
|
|
98
|
+
string workflow_id = 1;
|
|
99
|
+
string node_id = 2;
|
|
100
|
+
string workflow_data = 3; // Updated workflow data (JSON string)
|
|
101
|
+
map<string, string> metadata = 4; // Runtime metadata
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
message ResumeWorkflowResponse {
|
|
105
|
+
string workflow_id = 1;
|
|
106
|
+
WorkflowState state = 2;
|
|
107
|
+
bool success = 3;
|
|
108
|
+
string error = 4;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
service WorkflowService {
|
|
112
|
+
rpc CreateWorkflow(CreateWorkflowRequest) returns (CreateWorkflowResponse);
|
|
113
|
+
rpc StartWorkflow(StartWorkflowRequest) returns (StartWorkflowResponse);
|
|
114
|
+
rpc GetWorkflowState(GetWorkflowStateRequest) returns (GetWorkflowStateResponse);
|
|
115
|
+
rpc ResumeWorkflow(ResumeWorkflowRequest) returns (ResumeWorkflowResponse);
|
|
116
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
|
|
3
|
+
package sw4rm.worktree;
|
|
4
|
+
|
|
5
|
+
message BindRequest { string agent_id = 1; string repo_id = 2; string worktree_id = 3; }
|
|
6
|
+
message BindResponse { bool ok = 1; string reason = 2; }
|
|
7
|
+
|
|
8
|
+
message UnbindRequest { string agent_id = 1; }
|
|
9
|
+
message UnbindResponse { bool ok = 1; }
|
|
10
|
+
|
|
11
|
+
message SwitchRequest {
|
|
12
|
+
string agent_id = 1;
|
|
13
|
+
string target_worktree_id = 2;
|
|
14
|
+
bool requires_hitl = 3;
|
|
15
|
+
}
|
|
16
|
+
message SwitchApprove { string agent_id = 1; string target_worktree_id = 2; uint64 ttl_ms = 3; }
|
|
17
|
+
message SwitchReject { string agent_id = 1; string reason = 2; }
|
|
18
|
+
|
|
19
|
+
message StatusRequest { string agent_id = 1; }
|
|
20
|
+
message StatusResponse {
|
|
21
|
+
string repo_id = 1;
|
|
22
|
+
string worktree_id = 2;
|
|
23
|
+
string state = 3; // UNBOUND|BOUND_HOME|SWITCH_PENDING|BOUND_NON_HOME|BIND_FAILED
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
service WorktreeService {
|
|
27
|
+
rpc Bind(BindRequest) returns (BindResponse);
|
|
28
|
+
rpc Unbind(UnbindRequest) returns (UnbindResponse);
|
|
29
|
+
rpc RequestSwitch(SwitchRequest) returns (StatusResponse);
|
|
30
|
+
rpc ApproveSwitch(SwitchApprove) returns (StatusResponse);
|
|
31
|
+
rpc RejectSwitch(SwitchReject) returns (StatusResponse);
|
|
32
|
+
rpc Status(StatusRequest) returns (StatusResponse);
|
|
33
|
+
}
|