@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,80 @@
|
|
|
1
|
+
import type { HandoffRequest, HandoffResponse } from '../clients/handoff.js';
|
|
2
|
+
export declare const REGISTRATION_TYPE_STANDARD_AGENT = 1;
|
|
3
|
+
export declare const REGISTRATION_TYPE_SWARM_GATEWAY = 2;
|
|
4
|
+
export declare const AGENT_STATE_INITIALIZING = 1;
|
|
5
|
+
export declare const AGENT_STATE_RUNNING = 4;
|
|
6
|
+
export declare const AGENT_STATE_FAILED = 10;
|
|
7
|
+
export declare const AGENT_STATE_SHUTTING_DOWN = 11;
|
|
8
|
+
export declare const DEFAULT_PEER_LIVENESS_THRESHOLD_MS = 30000;
|
|
9
|
+
export declare const NON_SERVING_AGENT_STATES: Set<number>;
|
|
10
|
+
export interface GatewayPeerDescriptor {
|
|
11
|
+
agentId: string;
|
|
12
|
+
registrationType: number;
|
|
13
|
+
capabilities: string[];
|
|
14
|
+
}
|
|
15
|
+
export interface PeerRuntimeState {
|
|
16
|
+
state: number;
|
|
17
|
+
lastHeartbeatMs: number;
|
|
18
|
+
cooldownUntilMs: number;
|
|
19
|
+
}
|
|
20
|
+
export interface PeerSelectorOptions {
|
|
21
|
+
localAgentId: string;
|
|
22
|
+
localCapabilities: string[];
|
|
23
|
+
nowMsFn?: () => number;
|
|
24
|
+
peerHealthFn?: (peer: GatewayPeerDescriptor) => boolean;
|
|
25
|
+
livenessThresholdMs?: number;
|
|
26
|
+
}
|
|
27
|
+
export interface UpdatePeerRuntimeStateOptions {
|
|
28
|
+
state?: number;
|
|
29
|
+
lastHeartbeatMs?: number;
|
|
30
|
+
cooldownUntilMs?: number;
|
|
31
|
+
}
|
|
32
|
+
export interface RecordPeerOverloadedOptions {
|
|
33
|
+
retryAfterMs?: number;
|
|
34
|
+
localCooldownMs?: number;
|
|
35
|
+
}
|
|
36
|
+
export interface GatewayRedirectEmitterOptions {
|
|
37
|
+
agentId: string;
|
|
38
|
+
capabilities?: string[];
|
|
39
|
+
retryAfterMs?: number;
|
|
40
|
+
peerDescriptors?: GatewayPeerDescriptor[];
|
|
41
|
+
peerHealthFn?: (peer: GatewayPeerDescriptor) => boolean;
|
|
42
|
+
nowMsFn?: () => number;
|
|
43
|
+
peerLivenessThresholdMs?: number;
|
|
44
|
+
}
|
|
45
|
+
export declare class GatewayValidationError extends Error {
|
|
46
|
+
constructor(message: string);
|
|
47
|
+
}
|
|
48
|
+
export declare class PeerSelector {
|
|
49
|
+
private readonly localAgentId;
|
|
50
|
+
private readonly localCapabilities;
|
|
51
|
+
private readonly nowMs;
|
|
52
|
+
private readonly peerHealthFn;
|
|
53
|
+
private readonly livenessThresholdMs;
|
|
54
|
+
private peers;
|
|
55
|
+
private runtime;
|
|
56
|
+
private rrCursor;
|
|
57
|
+
constructor(options: PeerSelectorOptions);
|
|
58
|
+
setPeers(peers: GatewayPeerDescriptor[]): void;
|
|
59
|
+
updatePeerRuntimeState(agentId: string, options?: UpdatePeerRuntimeStateOptions): void;
|
|
60
|
+
touchPeerHeartbeat(agentId: string, options?: Pick<UpdatePeerRuntimeStateOptions, 'state'> & {
|
|
61
|
+
nowMs?: number;
|
|
62
|
+
}): void;
|
|
63
|
+
recordPeerOverloaded(agentId: string, options?: RecordPeerOverloadedOptions): void;
|
|
64
|
+
isEligible(peer: GatewayPeerDescriptor): boolean;
|
|
65
|
+
selectPeer(): string;
|
|
66
|
+
private ensureRuntime;
|
|
67
|
+
private isHealthy;
|
|
68
|
+
}
|
|
69
|
+
export declare class GatewayRedirectEmitter {
|
|
70
|
+
private readonly retryAfterMs;
|
|
71
|
+
private readonly peerSelector;
|
|
72
|
+
constructor(options: GatewayRedirectEmitterOptions);
|
|
73
|
+
setPeerDescriptors(peers: GatewayPeerDescriptor[]): void;
|
|
74
|
+
updatePeerRuntimeState(agentId: string, options?: UpdatePeerRuntimeStateOptions): void;
|
|
75
|
+
touchPeerHeartbeat(agentId: string, options?: Pick<UpdatePeerRuntimeStateOptions, 'state'> & {
|
|
76
|
+
nowMs?: number;
|
|
77
|
+
}): void;
|
|
78
|
+
recordPeerOverloaded(agentId: string, options?: RecordPeerOverloadedOptions): void;
|
|
79
|
+
emitOverloadedResponse(request: HandoffRequest): HandoffResponse;
|
|
80
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sw4rm/js-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "SW4RM Agentic Protocol JavaScript/TypeScript SDK",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/cjs/index.cjs",
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
"scripts": {
|
|
17
|
-
"build": "npm run build:proto && npm run build:lib",
|
|
17
|
+
"build": "npm run build:proto && npm run build:lib && npm run copy:protos",
|
|
18
|
+
"copy:protos": "rm -rf protos && cp -r ../../protos protos",
|
|
18
19
|
"example": "tsx",
|
|
19
20
|
"build:proto": "npm run proto:js && npm run proto:ts",
|
|
20
21
|
"build:lib": "npm run build:esm && npm run build:cjs && npm run build:types",
|
|
@@ -30,6 +31,7 @@
|
|
|
30
31
|
},
|
|
31
32
|
"files": [
|
|
32
33
|
"dist",
|
|
34
|
+
"protos",
|
|
33
35
|
"README.md",
|
|
34
36
|
"LICENSE"
|
|
35
37
|
],
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
|
|
3
|
+
package sw4rm.activity;
|
|
4
|
+
|
|
5
|
+
message Artifact {
|
|
6
|
+
string negotiation_id = 1;
|
|
7
|
+
string kind = 2; // contract|diff|decision|score|note
|
|
8
|
+
string version = 3; // e.g., v3
|
|
9
|
+
string content_type = 4;
|
|
10
|
+
bytes content = 5;
|
|
11
|
+
string created_at = 6; // ISO-8601
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
message AppendArtifactRequest { Artifact artifact = 1; }
|
|
15
|
+
message AppendArtifactResponse { bool ok = 1; string reason = 2; }
|
|
16
|
+
|
|
17
|
+
message ListArtifactsRequest { string negotiation_id = 1; string kind = 2; }
|
|
18
|
+
message ListArtifactsResponse { repeated Artifact items = 1; }
|
|
19
|
+
|
|
20
|
+
service ActivityService {
|
|
21
|
+
rpc AppendArtifact(AppendArtifactRequest) returns (AppendArtifactResponse);
|
|
22
|
+
rpc ListArtifacts(ListArtifactsRequest) returns (ListArtifactsResponse);
|
|
23
|
+
}
|
|
24
|
+
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
|
|
3
|
+
package sw4rm.common;
|
|
4
|
+
|
|
5
|
+
import "google/protobuf/timestamp.proto";
|
|
6
|
+
import "google/protobuf/duration.proto";
|
|
7
|
+
|
|
8
|
+
enum MessageType {
|
|
9
|
+
MESSAGE_TYPE_UNSPECIFIED = 0;
|
|
10
|
+
CONTROL = 1;
|
|
11
|
+
DATA = 2;
|
|
12
|
+
HEARTBEAT = 3;
|
|
13
|
+
NOTIFICATION = 4;
|
|
14
|
+
ACKNOWLEDGEMENT = 5;
|
|
15
|
+
HITL_INVOCATION = 6;
|
|
16
|
+
WORKTREE_CONTROL = 7;
|
|
17
|
+
NEGOTIATION = 8;
|
|
18
|
+
TOOL_CALL = 9;
|
|
19
|
+
TOOL_RESULT = 10;
|
|
20
|
+
TOOL_ERROR = 11;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
enum AckStage {
|
|
24
|
+
ACK_STAGE_UNSPECIFIED = 0;
|
|
25
|
+
RECEIVED = 1;
|
|
26
|
+
READ = 2;
|
|
27
|
+
FULFILLED = 3;
|
|
28
|
+
REJECTED = 4;
|
|
29
|
+
FAILED = 5;
|
|
30
|
+
TIMED_OUT = 6;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
enum ErrorCode {
|
|
34
|
+
ERROR_CODE_UNSPECIFIED = 0;
|
|
35
|
+
BUFFER_FULL = 1;
|
|
36
|
+
NO_ROUTE = 2;
|
|
37
|
+
ACK_TIMEOUT = 3;
|
|
38
|
+
AGENT_UNAVAILABLE = 4;
|
|
39
|
+
AGENT_SHUTDOWN = 5;
|
|
40
|
+
VALIDATION_ERROR = 6;
|
|
41
|
+
PERMISSION_DENIED = 7;
|
|
42
|
+
UNSUPPORTED_MESSAGE_TYPE = 8;
|
|
43
|
+
OVERSIZE_PAYLOAD = 9;
|
|
44
|
+
TOOL_TIMEOUT = 10;
|
|
45
|
+
PARTIAL_DELIVERY = 11; // reserved
|
|
46
|
+
FORCED_PREEMPTION = 12;
|
|
47
|
+
TTL_EXPIRED = 13;
|
|
48
|
+
DUPLICATE_DETECTED = 14;
|
|
49
|
+
ALREADY_IN_PROGRESS = 15;
|
|
50
|
+
// SW4-004 Inter-Swarm Composition (values 16-19)
|
|
51
|
+
OVERLOADED = 16;
|
|
52
|
+
// SW4-005 Spillover Routing (values 20-23)
|
|
53
|
+
REDIRECT = 20;
|
|
54
|
+
INTERNAL_ERROR = 99;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
enum AgentState {
|
|
58
|
+
AGENT_STATE_UNSPECIFIED = 0;
|
|
59
|
+
INITIALIZING = 1;
|
|
60
|
+
RUNNABLE = 2;
|
|
61
|
+
SCHEDULED = 3;
|
|
62
|
+
RUNNING = 4;
|
|
63
|
+
WAITING = 5;
|
|
64
|
+
WAITING_RESOURCES = 6;
|
|
65
|
+
SUSPENDED = 7;
|
|
66
|
+
RESUMED = 8;
|
|
67
|
+
COMPLETED = 9;
|
|
68
|
+
FAILED_STATE = 10;
|
|
69
|
+
SHUTTING_DOWN = 11;
|
|
70
|
+
RECOVERING = 12;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
enum CommunicationClass {
|
|
74
|
+
COMM_CLASS_UNSPECIFIED = 0;
|
|
75
|
+
PRIVILEGED = 1;
|
|
76
|
+
STANDARD = 2;
|
|
77
|
+
BULK = 3;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
enum DebateIntensity {
|
|
81
|
+
DEBATE_INTENSITY_UNSPECIFIED = 0;
|
|
82
|
+
LOWEST = 1;
|
|
83
|
+
LOW = 2;
|
|
84
|
+
MEDIUM = 3;
|
|
85
|
+
HIGH = 4;
|
|
86
|
+
HIGHEST = 5;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
enum HitlReasonType {
|
|
90
|
+
HITL_REASON_UNSPECIFIED = 0;
|
|
91
|
+
CONFLICT = 1;
|
|
92
|
+
SECURITY_APPROVAL = 2;
|
|
93
|
+
TASK_ESCALATION = 3;
|
|
94
|
+
MANUAL_OVERRIDE = 4;
|
|
95
|
+
WORKTREE_OVERRIDE = 5;
|
|
96
|
+
DEBATE_DEADLOCK = 6;
|
|
97
|
+
TOOL_PRIVILEGE_ESCALATION = 7;
|
|
98
|
+
CONNECTOR_APPROVAL = 8;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
enum EnvelopeState {
|
|
102
|
+
ENVELOPE_STATE_UNSPECIFIED = 0;
|
|
103
|
+
ENVELOPE_STATE_SENT = 1;
|
|
104
|
+
ENVELOPE_STATE_RECEIVED = 2;
|
|
105
|
+
ENVELOPE_STATE_READ = 3;
|
|
106
|
+
ENVELOPE_STATE_FULFILLED = 4;
|
|
107
|
+
ENVELOPE_STATE_REJECTED = 5;
|
|
108
|
+
ENVELOPE_STATE_FAILED = 6;
|
|
109
|
+
ENVELOPE_STATE_TIMED_OUT = 7;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
message Envelope {
|
|
113
|
+
string message_id = 1; // UUIDv4 per attempt
|
|
114
|
+
string idempotency_token = 2; // stable across retries (optional)
|
|
115
|
+
string producer_id = 3;
|
|
116
|
+
string correlation_id = 4;
|
|
117
|
+
uint64 sequence_number = 5;
|
|
118
|
+
uint32 retry_count = 6;
|
|
119
|
+
MessageType message_type = 7;
|
|
120
|
+
string content_type = 8; // e.g., application/json
|
|
121
|
+
uint64 content_length = 9;
|
|
122
|
+
string repo_id = 10; // optional
|
|
123
|
+
string worktree_id = 11; // optional
|
|
124
|
+
string hlc_timestamp = 12; // optional, string-form HLC
|
|
125
|
+
uint64 ttl_ms = 13; // optional
|
|
126
|
+
google.protobuf.Timestamp timestamp = 14;
|
|
127
|
+
bytes payload = 15; // serialized content per content_type
|
|
128
|
+
EnvelopeState state = 16; // lifecycle state of the envelope
|
|
129
|
+
|
|
130
|
+
// SW4-004 Inter-Swarm Composition (fields 100-109)
|
|
131
|
+
string parent_correlation_id = 100; // set on first envelope crossing a swarm boundary
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
message Ack {
|
|
135
|
+
string ack_for_message_id = 1;
|
|
136
|
+
AckStage ack_stage = 2;
|
|
137
|
+
ErrorCode error_code = 3;
|
|
138
|
+
string note = 4;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
message Empty {}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
|
|
3
|
+
package sw4rm.connector;
|
|
4
|
+
|
|
5
|
+
message ToolDescriptor {
|
|
6
|
+
string tool_name = 1;
|
|
7
|
+
string input_schema = 2; // JSON Schema or URL
|
|
8
|
+
string output_schema = 3;
|
|
9
|
+
bool idempotent = 4;
|
|
10
|
+
bool needs_worktree = 5;
|
|
11
|
+
uint32 default_timeout_s = 6;
|
|
12
|
+
uint32 max_concurrency = 7;
|
|
13
|
+
string side_effects = 8; // "filesystem","network", etc.
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
message ProviderRegisterRequest {
|
|
17
|
+
string provider_id = 1;
|
|
18
|
+
repeated ToolDescriptor tools = 2;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
message ProviderRegisterResponse { bool ok = 1; string reason = 2; }
|
|
22
|
+
|
|
23
|
+
message DescribeToolsRequest { string provider_id = 1; }
|
|
24
|
+
message DescribeToolsResponse { repeated ToolDescriptor tools = 1; }
|
|
25
|
+
|
|
26
|
+
service ConnectorService {
|
|
27
|
+
rpc RegisterProvider(ProviderRegisterRequest) returns (ProviderRegisterResponse);
|
|
28
|
+
rpc DescribeTools(DescribeToolsRequest) returns (DescribeToolsResponse);
|
|
29
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
// SW4RM Protocol - Handoff Proto Definition
|
|
2
|
+
// Namespace Convention: sw4rm.{service} (e.g., sw4rm.handoff)
|
|
3
|
+
// See: docs/IMPLEMENTATION_PLAN.md Phase 1.1 for namespace standards.
|
|
4
|
+
|
|
5
|
+
syntax = "proto3";
|
|
6
|
+
|
|
7
|
+
package sw4rm.handoff;
|
|
8
|
+
|
|
9
|
+
import "common.proto";
|
|
10
|
+
import "google/protobuf/duration.proto";
|
|
11
|
+
|
|
12
|
+
enum HandoffStatus {
|
|
13
|
+
HANDOFF_STATUS_UNSPECIFIED = 0;
|
|
14
|
+
PENDING = 1;
|
|
15
|
+
ACCEPTED = 2;
|
|
16
|
+
REJECTED = 3;
|
|
17
|
+
COMPLETED = 4;
|
|
18
|
+
EXPIRED = 5;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// SW4-004 Inter-Swarm Composition
|
|
22
|
+
message BudgetEnvelope {
|
|
23
|
+
uint64 token_budget_remaining = 1; // combined LLM input+output tokens
|
|
24
|
+
uint64 wall_time_remaining_ms = 2;
|
|
25
|
+
uint64 deadline_epoch_ms = 3;
|
|
26
|
+
uint32 current_depth = 4;
|
|
27
|
+
uint32 max_delegation_depth = 5;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
message SwarmDelegationPolicy {
|
|
31
|
+
uint32 max_retries_on_overloaded = 1;
|
|
32
|
+
uint64 initial_backoff_ms = 2;
|
|
33
|
+
double backoff_multiplier = 3;
|
|
34
|
+
uint64 max_backoff_ms = 4;
|
|
35
|
+
bool allow_spillover_routing = 5; // permits redirect to equivalent peer gateway
|
|
36
|
+
uint32 max_redirects = 6; // SW4-005 redirect chain limit
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
message CancelDelegation {
|
|
40
|
+
string correlation_id = 1; // identifies the delegation to cancel
|
|
41
|
+
string reason = 2; // human-readable cancellation reason
|
|
42
|
+
uint64 grace_period_ms = 3; // time for cleanup before forced termination (min 5000ms)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
message CancelDelegationResponse {
|
|
46
|
+
bool acknowledged = 1;
|
|
47
|
+
string message = 2;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
message HandoffRequest {
|
|
51
|
+
string request_id = 1;
|
|
52
|
+
string from_agent = 2;
|
|
53
|
+
string to_agent = 3;
|
|
54
|
+
string reason = 4;
|
|
55
|
+
bytes context_snapshot = 5;
|
|
56
|
+
repeated string capabilities_required = 6;
|
|
57
|
+
int32 priority = 7;
|
|
58
|
+
google.protobuf.Duration timeout = 8;
|
|
59
|
+
|
|
60
|
+
// SW4-004 Inter-Swarm Composition (fields 100-109)
|
|
61
|
+
BudgetEnvelope budget = 100;
|
|
62
|
+
SwarmDelegationPolicy delegation_policy = 101;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
message HandoffResponse {
|
|
66
|
+
string request_id = 1;
|
|
67
|
+
bool accepted = 2;
|
|
68
|
+
string accepting_agent = 3;
|
|
69
|
+
string rejection_reason = 4;
|
|
70
|
+
|
|
71
|
+
// SW4-004 Inter-Swarm Composition (fields 100-109)
|
|
72
|
+
sw4rm.common.ErrorCode rejection_code = 100;
|
|
73
|
+
uint64 retry_after_ms = 101;
|
|
74
|
+
|
|
75
|
+
// SW4-005 Spillover Routing (fields 110-119)
|
|
76
|
+
string redirect_to_agent_id = 110;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
message GetPendingHandoffsRequest {
|
|
80
|
+
string agent_id = 1;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
message GetPendingHandoffsResponse {
|
|
84
|
+
repeated HandoffRequest pending_requests = 1;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
message CompleteHandoffRequest {
|
|
88
|
+
string request_id = 1;
|
|
89
|
+
HandoffStatus status = 2;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
message CompleteHandoffResponse {
|
|
93
|
+
bool success = 1;
|
|
94
|
+
string message = 2;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
service HandoffService {
|
|
98
|
+
rpc RequestHandoff(HandoffRequest) returns (sw4rm.common.Empty);
|
|
99
|
+
rpc AcceptHandoff(HandoffResponse) returns (sw4rm.common.Empty);
|
|
100
|
+
rpc RejectHandoff(HandoffResponse) returns (sw4rm.common.Empty);
|
|
101
|
+
rpc GetPendingHandoffs(GetPendingHandoffsRequest) returns (GetPendingHandoffsResponse);
|
|
102
|
+
rpc CompleteHandoff(CompleteHandoffRequest) returns (CompleteHandoffResponse);
|
|
103
|
+
// SW4-004 Inter-Swarm Composition: cascading cancellation
|
|
104
|
+
rpc CancelDelegation(sw4rm.handoff.CancelDelegation) returns (CancelDelegationResponse);
|
|
105
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
|
|
3
|
+
package sw4rm.hitl;
|
|
4
|
+
|
|
5
|
+
import "common.proto";
|
|
6
|
+
|
|
7
|
+
message HitlInvocation {
|
|
8
|
+
sw4rm.common.HitlReasonType reason_type = 1;
|
|
9
|
+
bytes context = 2; // JSON or protobuf, see content_type in envelope
|
|
10
|
+
repeated string proposed_actions = 3;
|
|
11
|
+
int32 priority = 4;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
message HitlDecision {
|
|
15
|
+
string action = 1;
|
|
16
|
+
bytes decision_payload = 2;
|
|
17
|
+
string rationale = 3;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
service HitlService {
|
|
21
|
+
// Invocation is carried in Envelope.payload; this service handles the decision side.
|
|
22
|
+
rpc Decide(HitlInvocation) returns (HitlDecision);
|
|
23
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
|
|
3
|
+
package sw4rm.logging;
|
|
4
|
+
|
|
5
|
+
import "google/protobuf/timestamp.proto";
|
|
6
|
+
|
|
7
|
+
message LogEvent {
|
|
8
|
+
google.protobuf.Timestamp ts = 1;
|
|
9
|
+
string correlation_id = 2;
|
|
10
|
+
string agent_id = 3;
|
|
11
|
+
string event_type = 4;
|
|
12
|
+
string level = 5; // INFO|WARN|ERROR
|
|
13
|
+
string details_json = 6;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
message IngestResponse { bool ok = 1; }
|
|
17
|
+
|
|
18
|
+
service LoggingService {
|
|
19
|
+
rpc Ingest(LogEvent) returns (IngestResponse);
|
|
20
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
|
|
3
|
+
package sw4rm.negotiation;
|
|
4
|
+
|
|
5
|
+
import "common.proto";
|
|
6
|
+
import "google/protobuf/duration.proto";
|
|
7
|
+
|
|
8
|
+
message NegotiationOpen {
|
|
9
|
+
string negotiation_id = 1;
|
|
10
|
+
string correlation_id = 2;
|
|
11
|
+
string topic = 3;
|
|
12
|
+
repeated string participants = 4;
|
|
13
|
+
sw4rm.common.DebateIntensity intensity = 5;
|
|
14
|
+
google.protobuf.Duration debate_timeout = 6;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
message Proposal {
|
|
18
|
+
string negotiation_id = 1;
|
|
19
|
+
string from_agent = 2;
|
|
20
|
+
string content_type = 3;
|
|
21
|
+
bytes payload = 4; // schema/proto/text as declared
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
message CounterProposal {
|
|
25
|
+
string negotiation_id = 1;
|
|
26
|
+
string from_agent = 2;
|
|
27
|
+
string content_type = 3;
|
|
28
|
+
bytes payload = 4;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
message Evaluation {
|
|
32
|
+
string negotiation_id = 1;
|
|
33
|
+
string from_agent = 2;
|
|
34
|
+
double confidence_score = 3; // optional; 0 if absent
|
|
35
|
+
string notes = 4;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
message Decision {
|
|
39
|
+
string negotiation_id = 1;
|
|
40
|
+
string decided_by = 2; // "consensus"|"hitl"|"policy"
|
|
41
|
+
string content_type = 3;
|
|
42
|
+
bytes result = 4;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
message AbortRequest {
|
|
46
|
+
string negotiation_id = 1;
|
|
47
|
+
string reason = 2;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
service NegotiationService {
|
|
51
|
+
rpc Open(NegotiationOpen) returns (sw4rm.common.Empty);
|
|
52
|
+
rpc Propose(Proposal) returns (sw4rm.common.Empty);
|
|
53
|
+
rpc Counter(CounterProposal) returns (sw4rm.common.Empty);
|
|
54
|
+
rpc Evaluate(Evaluation) returns (sw4rm.common.Empty);
|
|
55
|
+
rpc Decide(Decision) returns (sw4rm.common.Empty);
|
|
56
|
+
rpc Abort(AbortRequest) returns (sw4rm.common.Empty);
|
|
57
|
+
}
|