@sw4rm/js-sdk 0.3.0 → 0.5.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 +13 -0
- package/dist/cjs/index.cjs +3576 -342
- package/dist/esm/index.js +3497 -336
- package/dist/types/agentConfig.d.ts +245 -0
- package/dist/types/audit.d.ts +214 -0
- package/dist/types/clients/handoff.d.ts +188 -0
- package/dist/types/clients/negotiationRoom.d.ts +423 -0
- package/dist/types/clients/negotiationRoomStore.d.ts +155 -0
- package/dist/types/clients/workflow.d.ts +316 -0
- package/dist/types/constants/index.d.ts +100 -0
- package/dist/types/index.d.ts +15 -4
- package/dist/types/internal/baseClient.d.ts +7 -1
- package/dist/types/internal/envelope.d.ts +16 -0
- package/dist/types/internal/errorMapping.d.ts +114 -0
- package/dist/types/internal/worktreeState.d.ts +60 -0
- package/dist/types/persistentActivityBuffer.d.ts +94 -0
- package/dist/types/runtime/agentState.d.ts +205 -0
- package/dist/types/runtime/policyStore.d.ts +391 -0
- package/dist/types/runtime/voting.d.ts +208 -0
- package/package.json +4 -2
- package/protos/activity.proto +24 -0
- package/protos/common.proto +134 -0
- package/protos/connector.proto +29 -0
- package/protos/handoff.proto +63 -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 +36 -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,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
|
+
}
|