@sw4rm/js-sdk 0.4.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 +1220 -178
- package/dist/esm/index.js +1174 -172
- package/dist/types/agentConfig.d.ts +245 -0
- package/dist/types/audit.d.ts +214 -0
- 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 +10 -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 +114 -0
- package/dist/types/internal/worktreeState.d.ts +60 -0
- package/dist/types/persistentActivityBuffer.d.ts +94 -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
package/dist/cjs/index.cjs
CHANGED
|
@@ -1859,7 +1859,7 @@ var require_fetch = __commonJS({
|
|
|
1859
1859
|
module2.exports = fetch;
|
|
1860
1860
|
var asPromise = require_aspromise();
|
|
1861
1861
|
var inquire2 = require_inquire();
|
|
1862
|
-
var
|
|
1862
|
+
var fs3 = inquire2("fs");
|
|
1863
1863
|
function fetch(filename, options, callback) {
|
|
1864
1864
|
if (typeof options === "function") {
|
|
1865
1865
|
callback = options;
|
|
@@ -1868,8 +1868,8 @@ var require_fetch = __commonJS({
|
|
|
1868
1868
|
options = {};
|
|
1869
1869
|
if (!callback)
|
|
1870
1870
|
return asPromise(fetch, this, filename, options);
|
|
1871
|
-
if (!options.xhr &&
|
|
1872
|
-
return
|
|
1871
|
+
if (!options.xhr && fs3 && fs3.readFile)
|
|
1872
|
+
return fs3.readFile(filename, function fetchReadFileCallback(err, contents) {
|
|
1873
1873
|
return err && typeof XMLHttpRequest !== "undefined" ? fetch.xhr(filename, options, callback) : err ? callback(err) : callback(null, options.binary ? contents : contents.toString("utf8"));
|
|
1874
1874
|
});
|
|
1875
1875
|
return fetch.xhr(filename, options, callback);
|
|
@@ -1907,15 +1907,15 @@ var require_fetch = __commonJS({
|
|
|
1907
1907
|
var require_path = __commonJS({
|
|
1908
1908
|
"node_modules/@protobufjs/path/index.js"(exports2) {
|
|
1909
1909
|
"use strict";
|
|
1910
|
-
var
|
|
1910
|
+
var path5 = exports2;
|
|
1911
1911
|
var isAbsolute = (
|
|
1912
1912
|
/**
|
|
1913
1913
|
* Tests if the specified path is absolute.
|
|
1914
1914
|
* @param {string} path Path to test
|
|
1915
1915
|
* @returns {boolean} `true` if path is absolute
|
|
1916
1916
|
*/
|
|
1917
|
-
|
|
1918
|
-
return /^(?:\/|\w+:)/.test(
|
|
1917
|
+
path5.isAbsolute = function isAbsolute2(path6) {
|
|
1918
|
+
return /^(?:\/|\w+:)/.test(path6);
|
|
1919
1919
|
}
|
|
1920
1920
|
);
|
|
1921
1921
|
var normalize = (
|
|
@@ -1924,9 +1924,9 @@ var require_path = __commonJS({
|
|
|
1924
1924
|
* @param {string} path Path to normalize
|
|
1925
1925
|
* @returns {string} Normalized path
|
|
1926
1926
|
*/
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
var parts =
|
|
1927
|
+
path5.normalize = function normalize2(path6) {
|
|
1928
|
+
path6 = path6.replace(/\\/g, "/").replace(/\/{2,}/g, "/");
|
|
1929
|
+
var parts = path6.split("/"), absolute = isAbsolute(path6), prefix = "";
|
|
1930
1930
|
if (absolute)
|
|
1931
1931
|
prefix = parts.shift() + "/";
|
|
1932
1932
|
for (var i = 0; i < parts.length; ) {
|
|
@@ -1945,7 +1945,7 @@ var require_path = __commonJS({
|
|
|
1945
1945
|
return prefix + parts.join("/");
|
|
1946
1946
|
}
|
|
1947
1947
|
);
|
|
1948
|
-
|
|
1948
|
+
path5.resolve = function resolve(originPath, includePath, alreadyNormalized) {
|
|
1949
1949
|
if (!alreadyNormalized)
|
|
1950
1950
|
includePath = normalize(includePath);
|
|
1951
1951
|
if (isAbsolute(includePath))
|
|
@@ -2096,16 +2096,16 @@ var require_namespace = __commonJS({
|
|
|
2096
2096
|
object.onRemove(this);
|
|
2097
2097
|
return clearCache(this);
|
|
2098
2098
|
};
|
|
2099
|
-
Namespace.prototype.define = function define2(
|
|
2100
|
-
if (util.isString(
|
|
2101
|
-
|
|
2102
|
-
else if (!Array.isArray(
|
|
2099
|
+
Namespace.prototype.define = function define2(path5, json) {
|
|
2100
|
+
if (util.isString(path5))
|
|
2101
|
+
path5 = path5.split(".");
|
|
2102
|
+
else if (!Array.isArray(path5))
|
|
2103
2103
|
throw TypeError("illegal path");
|
|
2104
|
-
if (
|
|
2104
|
+
if (path5 && path5.length && path5[0] === "")
|
|
2105
2105
|
throw Error("path must be relative");
|
|
2106
2106
|
var ptr = this;
|
|
2107
|
-
while (
|
|
2108
|
-
var part =
|
|
2107
|
+
while (path5.length > 0) {
|
|
2108
|
+
var part = path5.shift();
|
|
2109
2109
|
if (ptr.nested && ptr.nested[part]) {
|
|
2110
2110
|
ptr = ptr.nested[part];
|
|
2111
2111
|
if (!(ptr instanceof Namespace))
|
|
@@ -2142,26 +2142,26 @@ var require_namespace = __commonJS({
|
|
|
2142
2142
|
});
|
|
2143
2143
|
return this;
|
|
2144
2144
|
};
|
|
2145
|
-
Namespace.prototype.lookup = function lookup(
|
|
2145
|
+
Namespace.prototype.lookup = function lookup(path5, filterTypes, parentAlreadyChecked) {
|
|
2146
2146
|
if (typeof filterTypes === "boolean") {
|
|
2147
2147
|
parentAlreadyChecked = filterTypes;
|
|
2148
2148
|
filterTypes = void 0;
|
|
2149
2149
|
} else if (filterTypes && !Array.isArray(filterTypes))
|
|
2150
2150
|
filterTypes = [filterTypes];
|
|
2151
|
-
if (util.isString(
|
|
2152
|
-
if (
|
|
2151
|
+
if (util.isString(path5) && path5.length) {
|
|
2152
|
+
if (path5 === ".")
|
|
2153
2153
|
return this.root;
|
|
2154
|
-
|
|
2155
|
-
} else if (!
|
|
2154
|
+
path5 = path5.split(".");
|
|
2155
|
+
} else if (!path5.length)
|
|
2156
2156
|
return this;
|
|
2157
|
-
var flatPath =
|
|
2158
|
-
if (
|
|
2159
|
-
return this.root.lookup(
|
|
2157
|
+
var flatPath = path5.join(".");
|
|
2158
|
+
if (path5[0] === "")
|
|
2159
|
+
return this.root.lookup(path5.slice(1), filterTypes);
|
|
2160
2160
|
var found = this.root._fullyQualifiedObjects && this.root._fullyQualifiedObjects["." + flatPath];
|
|
2161
2161
|
if (found && (!filterTypes || filterTypes.indexOf(found.constructor) > -1)) {
|
|
2162
2162
|
return found;
|
|
2163
2163
|
}
|
|
2164
|
-
found = this._lookupImpl(
|
|
2164
|
+
found = this._lookupImpl(path5, flatPath);
|
|
2165
2165
|
if (found && (!filterTypes || filterTypes.indexOf(found.constructor) > -1)) {
|
|
2166
2166
|
return found;
|
|
2167
2167
|
}
|
|
@@ -2169,7 +2169,7 @@ var require_namespace = __commonJS({
|
|
|
2169
2169
|
return null;
|
|
2170
2170
|
var current = this;
|
|
2171
2171
|
while (current.parent) {
|
|
2172
|
-
found = current.parent._lookupImpl(
|
|
2172
|
+
found = current.parent._lookupImpl(path5, flatPath);
|
|
2173
2173
|
if (found && (!filterTypes || filterTypes.indexOf(found.constructor) > -1)) {
|
|
2174
2174
|
return found;
|
|
2175
2175
|
}
|
|
@@ -2177,49 +2177,49 @@ var require_namespace = __commonJS({
|
|
|
2177
2177
|
}
|
|
2178
2178
|
return null;
|
|
2179
2179
|
};
|
|
2180
|
-
Namespace.prototype._lookupImpl = function lookup(
|
|
2180
|
+
Namespace.prototype._lookupImpl = function lookup(path5, flatPath) {
|
|
2181
2181
|
if (Object.prototype.hasOwnProperty.call(this._lookupCache, flatPath)) {
|
|
2182
2182
|
return this._lookupCache[flatPath];
|
|
2183
2183
|
}
|
|
2184
|
-
var found = this.get(
|
|
2184
|
+
var found = this.get(path5[0]);
|
|
2185
2185
|
var exact = null;
|
|
2186
2186
|
if (found) {
|
|
2187
|
-
if (
|
|
2187
|
+
if (path5.length === 1) {
|
|
2188
2188
|
exact = found;
|
|
2189
2189
|
} else if (found instanceof Namespace) {
|
|
2190
|
-
|
|
2191
|
-
exact = found._lookupImpl(
|
|
2190
|
+
path5 = path5.slice(1);
|
|
2191
|
+
exact = found._lookupImpl(path5, path5.join("."));
|
|
2192
2192
|
}
|
|
2193
2193
|
} else {
|
|
2194
2194
|
for (var i = 0; i < this.nestedArray.length; ++i)
|
|
2195
|
-
if (this._nestedArray[i] instanceof Namespace && (found = this._nestedArray[i]._lookupImpl(
|
|
2195
|
+
if (this._nestedArray[i] instanceof Namespace && (found = this._nestedArray[i]._lookupImpl(path5, flatPath)))
|
|
2196
2196
|
exact = found;
|
|
2197
2197
|
}
|
|
2198
2198
|
this._lookupCache[flatPath] = exact;
|
|
2199
2199
|
return exact;
|
|
2200
2200
|
};
|
|
2201
|
-
Namespace.prototype.lookupType = function lookupType(
|
|
2202
|
-
var found = this.lookup(
|
|
2201
|
+
Namespace.prototype.lookupType = function lookupType(path5) {
|
|
2202
|
+
var found = this.lookup(path5, [Type]);
|
|
2203
2203
|
if (!found)
|
|
2204
|
-
throw Error("no such type: " +
|
|
2204
|
+
throw Error("no such type: " + path5);
|
|
2205
2205
|
return found;
|
|
2206
2206
|
};
|
|
2207
|
-
Namespace.prototype.lookupEnum = function lookupEnum(
|
|
2208
|
-
var found = this.lookup(
|
|
2207
|
+
Namespace.prototype.lookupEnum = function lookupEnum(path5) {
|
|
2208
|
+
var found = this.lookup(path5, [Enum]);
|
|
2209
2209
|
if (!found)
|
|
2210
|
-
throw Error("no such Enum '" +
|
|
2210
|
+
throw Error("no such Enum '" + path5 + "' in " + this);
|
|
2211
2211
|
return found;
|
|
2212
2212
|
};
|
|
2213
|
-
Namespace.prototype.lookupTypeOrEnum = function lookupTypeOrEnum(
|
|
2214
|
-
var found = this.lookup(
|
|
2213
|
+
Namespace.prototype.lookupTypeOrEnum = function lookupTypeOrEnum(path5) {
|
|
2214
|
+
var found = this.lookup(path5, [Type, Enum]);
|
|
2215
2215
|
if (!found)
|
|
2216
|
-
throw Error("no such Type or Enum '" +
|
|
2216
|
+
throw Error("no such Type or Enum '" + path5 + "' in " + this);
|
|
2217
2217
|
return found;
|
|
2218
2218
|
};
|
|
2219
|
-
Namespace.prototype.lookupService = function lookupService(
|
|
2220
|
-
var found = this.lookup(
|
|
2219
|
+
Namespace.prototype.lookupService = function lookupService(path5) {
|
|
2220
|
+
var found = this.lookup(path5, [Service]);
|
|
2221
2221
|
if (!found)
|
|
2222
|
-
throw Error("no such Service '" +
|
|
2222
|
+
throw Error("no such Service '" + path5 + "' in " + this);
|
|
2223
2223
|
return found;
|
|
2224
2224
|
};
|
|
2225
2225
|
Namespace._configure = function(Type_, Service_, Enum_) {
|
|
@@ -3620,14 +3620,14 @@ var require_util = __commonJS({
|
|
|
3620
3620
|
Object.defineProperty(object, "$type", { value: enm, enumerable: false });
|
|
3621
3621
|
return enm;
|
|
3622
3622
|
};
|
|
3623
|
-
util.setProperty = function setProperty(dst,
|
|
3624
|
-
function setProp(dst2,
|
|
3625
|
-
var part =
|
|
3623
|
+
util.setProperty = function setProperty(dst, path5, value, ifNotSet) {
|
|
3624
|
+
function setProp(dst2, path6, value2) {
|
|
3625
|
+
var part = path6.shift();
|
|
3626
3626
|
if (part === "__proto__" || part === "prototype") {
|
|
3627
3627
|
return dst2;
|
|
3628
3628
|
}
|
|
3629
|
-
if (
|
|
3630
|
-
dst2[part] = setProp(dst2[part] || {},
|
|
3629
|
+
if (path6.length > 0) {
|
|
3630
|
+
dst2[part] = setProp(dst2[part] || {}, path6, value2);
|
|
3631
3631
|
} else {
|
|
3632
3632
|
var prevValue = dst2[part];
|
|
3633
3633
|
if (prevValue && ifNotSet)
|
|
@@ -3640,10 +3640,10 @@ var require_util = __commonJS({
|
|
|
3640
3640
|
}
|
|
3641
3641
|
if (typeof dst !== "object")
|
|
3642
3642
|
throw TypeError("dst must be an object");
|
|
3643
|
-
if (!
|
|
3643
|
+
if (!path5)
|
|
3644
3644
|
throw TypeError("path must be specified");
|
|
3645
|
-
|
|
3646
|
-
return setProp(dst,
|
|
3645
|
+
path5 = path5.split(".");
|
|
3646
|
+
return setProp(dst, path5, value);
|
|
3647
3647
|
};
|
|
3648
3648
|
Object.defineProperty(util, "decorateRoot", {
|
|
3649
3649
|
get: function() {
|
|
@@ -4190,12 +4190,12 @@ var require_object = __commonJS({
|
|
|
4190
4190
|
*/
|
|
4191
4191
|
fullName: {
|
|
4192
4192
|
get: function() {
|
|
4193
|
-
var
|
|
4193
|
+
var path5 = [this.name], ptr = this.parent;
|
|
4194
4194
|
while (ptr) {
|
|
4195
|
-
|
|
4195
|
+
path5.unshift(ptr.name);
|
|
4196
4196
|
ptr = ptr.parent;
|
|
4197
4197
|
}
|
|
4198
|
-
return
|
|
4198
|
+
return path5.join(".");
|
|
4199
4199
|
}
|
|
4200
4200
|
}
|
|
4201
4201
|
});
|
|
@@ -8177,19 +8177,19 @@ var require_util2 = __commonJS({
|
|
|
8177
8177
|
"use strict";
|
|
8178
8178
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
8179
8179
|
exports2.addCommonProtos = exports2.loadProtosWithOptionsSync = exports2.loadProtosWithOptions = void 0;
|
|
8180
|
-
var
|
|
8181
|
-
var
|
|
8180
|
+
var fs3 = require("fs");
|
|
8181
|
+
var path5 = require("path");
|
|
8182
8182
|
var Protobuf = require_protobufjs();
|
|
8183
8183
|
function addIncludePathResolver(root, includePaths) {
|
|
8184
8184
|
const originalResolvePath = root.resolvePath;
|
|
8185
8185
|
root.resolvePath = (origin, target) => {
|
|
8186
|
-
if (
|
|
8186
|
+
if (path5.isAbsolute(target)) {
|
|
8187
8187
|
return target;
|
|
8188
8188
|
}
|
|
8189
8189
|
for (const directory of includePaths) {
|
|
8190
|
-
const fullPath =
|
|
8190
|
+
const fullPath = path5.join(directory, target);
|
|
8191
8191
|
try {
|
|
8192
|
-
|
|
8192
|
+
fs3.accessSync(fullPath, fs3.constants.R_OK);
|
|
8193
8193
|
return fullPath;
|
|
8194
8194
|
} catch (err) {
|
|
8195
8195
|
continue;
|
|
@@ -9483,7 +9483,7 @@ var require_src2 = __commonJS({
|
|
|
9483
9483
|
var src_exports = {};
|
|
9484
9484
|
__export(src_exports, {
|
|
9485
9485
|
ACKLifecycleManager: () => ACKLifecycleManager,
|
|
9486
|
-
AckStage: () =>
|
|
9486
|
+
AckStage: () => AckStage2,
|
|
9487
9487
|
ActivityBuffer: () => ActivityBuffer,
|
|
9488
9488
|
ActivityBufferSync: () => ActivityBufferSync,
|
|
9489
9489
|
ActivityClient: () => ActivityClient,
|
|
@@ -9492,15 +9492,22 @@ __export(src_exports, {
|
|
|
9492
9492
|
ArtifactType: () => ArtifactType,
|
|
9493
9493
|
BaseClient: () => BaseClient,
|
|
9494
9494
|
BordaCountAggregator: () => BordaCountAggregator,
|
|
9495
|
+
BufferFullError: () => BufferFullError,
|
|
9495
9496
|
CT_AGENT_REPORT_V1: () => CT_AGENT_REPORT_V1,
|
|
9496
9497
|
CT_SCHEDULER_COMMAND_V1: () => CT_SCHEDULER_COMMAND_V1,
|
|
9498
|
+
CommunicationClass: () => CommunicationClass,
|
|
9497
9499
|
ConfidenceWeightedAggregator: () => ConfidenceWeightedAggregator,
|
|
9498
9500
|
ConnectorClient: () => ConnectorClient,
|
|
9501
|
+
DEDUP_WINDOW_S: () => DEDUP_WINDOW_S,
|
|
9502
|
+
DEFAULT_ACK_TIMEOUT_MS: () => DEFAULT_ACK_TIMEOUT_MS,
|
|
9499
9503
|
DEFAULT_ESCALATION_POLICY: () => DEFAULT_ESCALATION_POLICY,
|
|
9500
9504
|
DEFAULT_EXECUTION_POLICY: () => DEFAULT_EXECUTION_POLICY,
|
|
9501
9505
|
DEFAULT_NEGOTIATION_POLICY: () => DEFAULT_NEGOTIATION_POLICY,
|
|
9506
|
+
DebateIntensity: () => DebateIntensity,
|
|
9502
9507
|
DecisionOutcome: () => DecisionOutcome,
|
|
9503
9508
|
DefaultWorktreePolicy: () => DefaultWorktreePolicy,
|
|
9509
|
+
DuplicateDetectedError: () => DuplicateDetectedError,
|
|
9510
|
+
EnvelopeState: () => EnvelopeState,
|
|
9504
9511
|
ErrorCode: () => ErrorCode,
|
|
9505
9512
|
ErrorCodeMapper: () => ErrorCodeMapper,
|
|
9506
9513
|
FileBackend: () => FileBackend,
|
|
@@ -9510,6 +9517,9 @@ __export(src_exports, {
|
|
|
9510
9517
|
HandoffTimeoutError: () => HandoffTimeoutError,
|
|
9511
9518
|
HandoffValidationError: () => HandoffValidationError,
|
|
9512
9519
|
HitlMode: () => HitlMode,
|
|
9520
|
+
HitlReasonType: () => HitlReasonType,
|
|
9521
|
+
InMemoryAuditor: () => InMemoryAuditor,
|
|
9522
|
+
InMemoryNegotiationRoomStore: () => InMemoryNegotiationRoomStore,
|
|
9513
9523
|
InMemoryPolicyStore: () => InMemoryPolicyStore,
|
|
9514
9524
|
InterceptorChain: () => InterceptorChain,
|
|
9515
9525
|
JSONFilePersistence: () => JSONFilePersistence,
|
|
@@ -9521,15 +9531,23 @@ __export(src_exports, {
|
|
|
9521
9531
|
MessageProcessor: () => MessageProcessor,
|
|
9522
9532
|
MessageType: () => MessageType,
|
|
9523
9533
|
NegotiationClient: () => NegotiationClient,
|
|
9534
|
+
NegotiationError: () => NegotiationError,
|
|
9524
9535
|
NegotiationRoomClient: () => NegotiationRoomClient,
|
|
9536
|
+
NegotiationRoomStoreError: () => NegotiationRoomStoreError,
|
|
9525
9537
|
NegotiationTimeoutError: () => NegotiationTimeoutError,
|
|
9526
9538
|
NegotiationValidationError: () => NegotiationValidationError,
|
|
9539
|
+
NoOpAuditor: () => NoOpAuditor,
|
|
9527
9540
|
NodeStatus: () => NodeStatus,
|
|
9541
|
+
PermissionError: () => PermissionError,
|
|
9542
|
+
PersistentActivityBuffer: () => PersistentActivityBuffer,
|
|
9528
9543
|
PersistentWorktreeState: () => PersistentWorktreeState,
|
|
9529
9544
|
PolicyStoreError: () => PolicyStoreError,
|
|
9545
|
+
PolicyViolationError: () => PolicyViolationError,
|
|
9546
|
+
PreemptionError: () => PreemptionError,
|
|
9530
9547
|
ReasoningClient: () => ReasoningClient,
|
|
9531
9548
|
RegistryClient: () => RegistryClient,
|
|
9532
9549
|
Resolver: () => Resolver,
|
|
9550
|
+
RouteError: () => RouteError,
|
|
9533
9551
|
RouterClient: () => RouterClient,
|
|
9534
9552
|
RuntimePersistence: () => RuntimePersistence,
|
|
9535
9553
|
SchedulerClient: () => SchedulerClient,
|
|
@@ -9547,40 +9565,63 @@ __export(src_exports, {
|
|
|
9547
9565
|
SimpleAverageAggregator: () => SimpleAverageAggregator,
|
|
9548
9566
|
StateTransitionError: () => StateTransitionError,
|
|
9549
9567
|
Sw4rmError: () => Sw4rmError,
|
|
9568
|
+
TimeoutError: () => TimeoutError,
|
|
9550
9569
|
ToolClient: () => ToolClient,
|
|
9551
9570
|
TriggerType: () => TriggerType,
|
|
9571
|
+
ValidationError: () => ValidationError,
|
|
9552
9572
|
VotingAnalyzer: () => VotingAnalyzer,
|
|
9553
9573
|
WorkflowClient: () => WorkflowClient,
|
|
9554
9574
|
WorkflowCycleError: () => WorkflowCycleError,
|
|
9555
9575
|
WorkflowStatus: () => WorkflowStatus,
|
|
9556
9576
|
WorkflowValidationError: () => WorkflowValidationError,
|
|
9557
9577
|
WorktreeClient: () => WorktreeClient,
|
|
9578
|
+
WorktreeError: () => WorktreeError,
|
|
9579
|
+
WorktreeStateEnum: () => WorktreeStateEnum,
|
|
9580
|
+
WorktreeTransitionError: () => WorktreeTransitionError,
|
|
9558
9581
|
aggregateVotes: () => aggregateVotes,
|
|
9559
9582
|
buildAckEnvelope: () => buildAckEnvelope,
|
|
9560
9583
|
buildEnvelope: () => buildEnvelope,
|
|
9584
|
+
computeEnvelopeHash: () => computeEnvelopeHash,
|
|
9561
9585
|
computeIdempotencyToken: () => computeIdempotencyToken,
|
|
9562
9586
|
createResilientIncomingStream: () => createResilientIncomingStream,
|
|
9587
|
+
createSimpleProof: () => createSimpleProof,
|
|
9563
9588
|
decodeAgentReportV1: () => decodeAgentReportV1,
|
|
9564
9589
|
decodeBase64: () => decodeBase64,
|
|
9590
|
+
defaultAgentConfig: () => defaultAgentConfig,
|
|
9591
|
+
defaultEndpoints: () => defaultEndpoints,
|
|
9592
|
+
defaultRetryPolicy: () => defaultRetryPolicy,
|
|
9593
|
+
defaultSW4RMConfig: () => defaultSW4RMConfig,
|
|
9565
9594
|
durationToMs: () => durationToMs,
|
|
9566
9595
|
encodeSchedulerCommandV1: () => encodeSchedulerCommandV1,
|
|
9596
|
+
getConfig: () => getConfig,
|
|
9597
|
+
getDefaultStore: () => getDefaultStore,
|
|
9567
9598
|
getValidTransitions: () => getValidTransitions,
|
|
9599
|
+
isTerminalEnvelopeState: () => isTerminalEnvelopeState,
|
|
9568
9600
|
isValidTransition: () => isValidTransition,
|
|
9601
|
+
isValidWorktreeTransition: () => isValidWorktreeTransition,
|
|
9602
|
+
loadConfig: () => loadConfig,
|
|
9603
|
+
loadConfigFromEnv: () => loadConfigFromEnv,
|
|
9569
9604
|
loggingInterceptor: () => loggingInterceptor,
|
|
9570
9605
|
mapGrpcStatusToErrorCode: () => mapGrpcStatusToErrorCode,
|
|
9571
9606
|
msToDuration: () => msToDuration,
|
|
9572
9607
|
normalizeReportPaths: () => normalizeReportPaths,
|
|
9573
9608
|
nowTimestamp: () => nowTimestamp,
|
|
9574
9609
|
parseNegotiationEvent: () => parseNegotiationEvent,
|
|
9610
|
+
resetConfig: () => resetConfig,
|
|
9611
|
+
resetDefaultStore: () => resetDefaultStore,
|
|
9575
9612
|
selectBackend: () => selectBackend,
|
|
9576
9613
|
sendMessageWithAck: () => sendMessageWithAck,
|
|
9614
|
+
setConfig: () => setConfig,
|
|
9577
9615
|
timingInterceptor: () => timingInterceptor,
|
|
9616
|
+
updateEnvelopeState: () => updateEnvelopeState,
|
|
9578
9617
|
uuidv4: () => uuidv4,
|
|
9618
|
+
verifyAuditProof: () => verifyAuditProof,
|
|
9579
9619
|
version: () => version
|
|
9580
9620
|
});
|
|
9581
9621
|
module.exports = __toCommonJS(src_exports);
|
|
9582
9622
|
|
|
9583
9623
|
// src/internal/baseClient.ts
|
|
9624
|
+
var import_node_fs = __toESM(require("node:fs"), 1);
|
|
9584
9625
|
var import_node_path = __toESM(require("node:path"), 1);
|
|
9585
9626
|
var import_node_url = require("node:url");
|
|
9586
9627
|
var grpc = __toESM(require("@grpc/grpc-js"), 1);
|
|
@@ -9602,6 +9643,8 @@ var ErrorCode = /* @__PURE__ */ ((ErrorCode2) => {
|
|
|
9602
9643
|
ErrorCode2[ErrorCode2["PARTIAL_DELIVERY"] = 11] = "PARTIAL_DELIVERY";
|
|
9603
9644
|
ErrorCode2[ErrorCode2["FORCED_PREEMPTION"] = 12] = "FORCED_PREEMPTION";
|
|
9604
9645
|
ErrorCode2[ErrorCode2["TTL_EXPIRED"] = 13] = "TTL_EXPIRED";
|
|
9646
|
+
ErrorCode2[ErrorCode2["DUPLICATE_DETECTED"] = 14] = "DUPLICATE_DETECTED";
|
|
9647
|
+
ErrorCode2[ErrorCode2["ALREADY_IN_PROGRESS"] = 15] = "ALREADY_IN_PROGRESS";
|
|
9605
9648
|
ErrorCode2[ErrorCode2["INTERNAL_ERROR"] = 99] = "INTERNAL_ERROR";
|
|
9606
9649
|
return ErrorCode2;
|
|
9607
9650
|
})(ErrorCode || {});
|
|
@@ -9617,6 +9660,54 @@ var Sw4rmError = class extends Error {
|
|
|
9617
9660
|
this.details = opts?.details;
|
|
9618
9661
|
}
|
|
9619
9662
|
};
|
|
9663
|
+
var ValidationError = class extends Sw4rmError {
|
|
9664
|
+
constructor(message, code = 6 /* VALIDATION_ERROR */, opts) {
|
|
9665
|
+
super(message, code, opts);
|
|
9666
|
+
this.name = "ValidationError";
|
|
9667
|
+
}
|
|
9668
|
+
};
|
|
9669
|
+
var TimeoutError = class extends Sw4rmError {
|
|
9670
|
+
constructor(message, code = 3 /* ACK_TIMEOUT */, opts) {
|
|
9671
|
+
super(message, code, opts);
|
|
9672
|
+
this.name = "TimeoutError";
|
|
9673
|
+
}
|
|
9674
|
+
};
|
|
9675
|
+
var StateTransitionError = class extends Sw4rmError {
|
|
9676
|
+
constructor(message, code = 99 /* INTERNAL_ERROR */, opts) {
|
|
9677
|
+
super(message, code, opts);
|
|
9678
|
+
this.name = "StateTransitionError";
|
|
9679
|
+
}
|
|
9680
|
+
};
|
|
9681
|
+
var NegotiationError = class extends Sw4rmError {
|
|
9682
|
+
constructor(message, code = 99 /* INTERNAL_ERROR */, opts) {
|
|
9683
|
+
super(message, code, opts);
|
|
9684
|
+
this.name = "NegotiationError";
|
|
9685
|
+
}
|
|
9686
|
+
};
|
|
9687
|
+
var BufferFullError = class extends Sw4rmError {
|
|
9688
|
+
constructor(message, code = 1 /* BUFFER_FULL */, opts) {
|
|
9689
|
+
super(message, code, opts);
|
|
9690
|
+
this.name = "BufferFullError";
|
|
9691
|
+
}
|
|
9692
|
+
};
|
|
9693
|
+
var RouteError = class extends Sw4rmError {
|
|
9694
|
+
constructor(message, code = 2 /* NO_ROUTE */, opts) {
|
|
9695
|
+
super(message, code, opts);
|
|
9696
|
+
this.name = "RouteError";
|
|
9697
|
+
}
|
|
9698
|
+
};
|
|
9699
|
+
var PermissionError = class extends Sw4rmError {
|
|
9700
|
+
constructor(message, code = 7 /* PERMISSION_DENIED */, opts) {
|
|
9701
|
+
super(message, code, opts);
|
|
9702
|
+
this.name = "PermissionError";
|
|
9703
|
+
}
|
|
9704
|
+
};
|
|
9705
|
+
var DuplicateDetectedError = class extends Sw4rmError {
|
|
9706
|
+
constructor(message, code = 14 /* DUPLICATE_DETECTED */, opts) {
|
|
9707
|
+
super(message, code, opts);
|
|
9708
|
+
this.name = "DuplicateDetectedError";
|
|
9709
|
+
}
|
|
9710
|
+
};
|
|
9620
9711
|
var GrpcStatus = {
|
|
9621
9712
|
OK: 0,
|
|
9622
9713
|
CANCELLED: 1,
|
|
@@ -9636,6 +9727,28 @@ var GrpcStatus = {
|
|
|
9636
9727
|
DATA_LOSS: 15,
|
|
9637
9728
|
UNAUTHENTICATED: 16
|
|
9638
9729
|
};
|
|
9730
|
+
var PreemptionError = class extends Sw4rmError {
|
|
9731
|
+
agentId;
|
|
9732
|
+
reason;
|
|
9733
|
+
constructor(agentId, reason, code = 12 /* FORCED_PREEMPTION */, opts) {
|
|
9734
|
+
super(`Agent ${agentId} preempted: ${reason}`, code, opts);
|
|
9735
|
+
this.name = "PreemptionError";
|
|
9736
|
+
this.agentId = agentId;
|
|
9737
|
+
this.reason = reason;
|
|
9738
|
+
}
|
|
9739
|
+
};
|
|
9740
|
+
var WorktreeError = class extends Sw4rmError {
|
|
9741
|
+
constructor(message, code = 99 /* INTERNAL_ERROR */, opts) {
|
|
9742
|
+
super(message, code, opts);
|
|
9743
|
+
this.name = "WorktreeError";
|
|
9744
|
+
}
|
|
9745
|
+
};
|
|
9746
|
+
var PolicyViolationError = class extends Sw4rmError {
|
|
9747
|
+
constructor(message, code = 7 /* PERMISSION_DENIED */, opts) {
|
|
9748
|
+
super(message, code, opts);
|
|
9749
|
+
this.name = "PolicyViolationError";
|
|
9750
|
+
}
|
|
9751
|
+
};
|
|
9639
9752
|
function mapGrpcStatusToErrorCode(status) {
|
|
9640
9753
|
switch (status) {
|
|
9641
9754
|
case GrpcStatus.OK:
|
|
@@ -9750,12 +9863,12 @@ var BaseClient = class {
|
|
|
9750
9863
|
errorMapper = new ErrorCodeMapper();
|
|
9751
9864
|
constructor(opts) {
|
|
9752
9865
|
this.address = opts.address;
|
|
9753
|
-
this.deadlineMs = opts.deadlineMs ??
|
|
9866
|
+
this.deadlineMs = opts.deadlineMs ?? 3e4;
|
|
9754
9867
|
this.retry = opts.retry ?? { maxAttempts: 3, initialBackoffMs: 200, maxBackoffMs: 2e3, multiplier: 2 };
|
|
9755
9868
|
this.userAgent = opts.userAgent ?? "sw4rm-js-sdk/0.1";
|
|
9756
9869
|
const __filename = (0, import_node_url.fileURLToPath)(import_meta.url);
|
|
9757
9870
|
const __dirname = import_node_path.default.dirname(__filename);
|
|
9758
|
-
const protosDir =
|
|
9871
|
+
const protosDir = this.resolveProtosDir(__dirname);
|
|
9759
9872
|
const loaderOpts = {
|
|
9760
9873
|
keepCase: true,
|
|
9761
9874
|
longs: String,
|
|
@@ -9775,10 +9888,13 @@ var BaseClient = class {
|
|
|
9775
9888
|
"tool.proto",
|
|
9776
9889
|
"connector.proto",
|
|
9777
9890
|
"negotiation.proto",
|
|
9891
|
+
"negotiation_room.proto",
|
|
9778
9892
|
"reasoning.proto",
|
|
9779
9893
|
"logging.proto",
|
|
9780
9894
|
"policy.proto",
|
|
9781
|
-
"activity.proto"
|
|
9895
|
+
"activity.proto",
|
|
9896
|
+
"handoff.proto",
|
|
9897
|
+
"workflow.proto"
|
|
9782
9898
|
], loaderOpts);
|
|
9783
9899
|
this.root = grpc.loadPackageDefinition(this.pkgDef);
|
|
9784
9900
|
this.interceptors.use(timingInterceptor());
|
|
@@ -9788,6 +9904,27 @@ var BaseClient = class {
|
|
|
9788
9904
|
if (opts.errorMapper)
|
|
9789
9905
|
opts.errorMapper(this.errorMapper);
|
|
9790
9906
|
}
|
|
9907
|
+
/**
|
|
9908
|
+
* Resolves the protos directory, checking multiple locations:
|
|
9909
|
+
* 1. npm package: ./protos relative to package root
|
|
9910
|
+
* 2. Monorepo dev: ../../../../protos relative to this file
|
|
9911
|
+
*/
|
|
9912
|
+
resolveProtosDir(dirname3) {
|
|
9913
|
+
const candidates = [
|
|
9914
|
+
// npm package structure: node_modules/@sw4rm/js-sdk/protos
|
|
9915
|
+
import_node_path.default.resolve(dirname3, "../../protos"),
|
|
9916
|
+
// Alternative npm structure: dist/esm/internal -> protos
|
|
9917
|
+
import_node_path.default.resolve(dirname3, "../../../protos"),
|
|
9918
|
+
// Monorepo development: sdks/js_sdk/src/internal -> protos
|
|
9919
|
+
import_node_path.default.resolve(dirname3, "../../../../protos")
|
|
9920
|
+
];
|
|
9921
|
+
for (const candidate of candidates) {
|
|
9922
|
+
if (import_node_fs.default.existsSync(candidate) && import_node_fs.default.existsSync(import_node_path.default.join(candidate, "common.proto"))) {
|
|
9923
|
+
return candidate;
|
|
9924
|
+
}
|
|
9925
|
+
}
|
|
9926
|
+
return candidates[candidates.length - 1];
|
|
9927
|
+
}
|
|
9791
9928
|
channelCredentials() {
|
|
9792
9929
|
return grpc.credentials.createInsecure();
|
|
9793
9930
|
}
|
|
@@ -10375,6 +10512,95 @@ var RegistryClient = class extends BaseClient {
|
|
|
10375
10512
|
}
|
|
10376
10513
|
};
|
|
10377
10514
|
|
|
10515
|
+
// src/clients/negotiationRoomStore.ts
|
|
10516
|
+
var NegotiationRoomStoreError = class extends Error {
|
|
10517
|
+
constructor(message) {
|
|
10518
|
+
super(message);
|
|
10519
|
+
this.name = "NegotiationRoomStoreError";
|
|
10520
|
+
}
|
|
10521
|
+
};
|
|
10522
|
+
var InMemoryNegotiationRoomStore = class {
|
|
10523
|
+
proposals = /* @__PURE__ */ new Map();
|
|
10524
|
+
votes = /* @__PURE__ */ new Map();
|
|
10525
|
+
decisions = /* @__PURE__ */ new Map();
|
|
10526
|
+
async hasProposal(artifactId) {
|
|
10527
|
+
return this.proposals.has(artifactId);
|
|
10528
|
+
}
|
|
10529
|
+
async getProposal(artifactId) {
|
|
10530
|
+
return this.proposals.get(artifactId) || null;
|
|
10531
|
+
}
|
|
10532
|
+
async saveProposal(proposal) {
|
|
10533
|
+
const artifactId = proposal.artifactId;
|
|
10534
|
+
if (this.proposals.has(artifactId)) {
|
|
10535
|
+
throw new NegotiationRoomStoreError(
|
|
10536
|
+
`Proposal with artifact_id '${artifactId}' already exists`
|
|
10537
|
+
);
|
|
10538
|
+
}
|
|
10539
|
+
const proposalWithTimestamp = {
|
|
10540
|
+
...proposal,
|
|
10541
|
+
createdAt: proposal.createdAt || (/* @__PURE__ */ new Date()).toISOString()
|
|
10542
|
+
};
|
|
10543
|
+
this.proposals.set(artifactId, proposalWithTimestamp);
|
|
10544
|
+
this.votes.set(artifactId, []);
|
|
10545
|
+
}
|
|
10546
|
+
async listProposals(negotiationRoomId) {
|
|
10547
|
+
const allProposals = Array.from(this.proposals.values());
|
|
10548
|
+
if (negotiationRoomId === void 0) {
|
|
10549
|
+
return allProposals;
|
|
10550
|
+
}
|
|
10551
|
+
return allProposals.filter((p) => p.negotiationRoomId === negotiationRoomId);
|
|
10552
|
+
}
|
|
10553
|
+
async getVotes(artifactId) {
|
|
10554
|
+
return [...this.votes.get(artifactId) || []];
|
|
10555
|
+
}
|
|
10556
|
+
async addVote(vote) {
|
|
10557
|
+
const artifactId = vote.artifactId;
|
|
10558
|
+
const criticId = vote.criticId;
|
|
10559
|
+
const existingVotes = this.votes.get(artifactId) || [];
|
|
10560
|
+
for (const existingVote of existingVotes) {
|
|
10561
|
+
if (existingVote.criticId === criticId) {
|
|
10562
|
+
throw new NegotiationRoomStoreError(
|
|
10563
|
+
`Critic '${criticId}' has already voted for artifact '${artifactId}'`
|
|
10564
|
+
);
|
|
10565
|
+
}
|
|
10566
|
+
}
|
|
10567
|
+
const voteWithTimestamp = {
|
|
10568
|
+
...vote,
|
|
10569
|
+
votedAt: vote.votedAt || (/* @__PURE__ */ new Date()).toISOString()
|
|
10570
|
+
};
|
|
10571
|
+
if (!this.votes.has(artifactId)) {
|
|
10572
|
+
this.votes.set(artifactId, []);
|
|
10573
|
+
}
|
|
10574
|
+
this.votes.get(artifactId).push(voteWithTimestamp);
|
|
10575
|
+
}
|
|
10576
|
+
async getDecision(artifactId) {
|
|
10577
|
+
return this.decisions.get(artifactId) || null;
|
|
10578
|
+
}
|
|
10579
|
+
async saveDecision(decision) {
|
|
10580
|
+
const artifactId = decision.artifactId;
|
|
10581
|
+
if (this.decisions.has(artifactId)) {
|
|
10582
|
+
throw new NegotiationRoomStoreError(
|
|
10583
|
+
`Decision already exists for artifact_id '${artifactId}'`
|
|
10584
|
+
);
|
|
10585
|
+
}
|
|
10586
|
+
const decisionWithTimestamp = {
|
|
10587
|
+
...decision,
|
|
10588
|
+
decidedAt: decision.decidedAt || (/* @__PURE__ */ new Date()).toISOString()
|
|
10589
|
+
};
|
|
10590
|
+
this.decisions.set(artifactId, decisionWithTimestamp);
|
|
10591
|
+
}
|
|
10592
|
+
};
|
|
10593
|
+
var defaultStore = null;
|
|
10594
|
+
function getDefaultStore() {
|
|
10595
|
+
if (defaultStore === null) {
|
|
10596
|
+
defaultStore = new InMemoryNegotiationRoomStore();
|
|
10597
|
+
}
|
|
10598
|
+
return defaultStore;
|
|
10599
|
+
}
|
|
10600
|
+
function resetDefaultStore() {
|
|
10601
|
+
defaultStore = null;
|
|
10602
|
+
}
|
|
10603
|
+
|
|
10378
10604
|
// src/clients/negotiationRoom.ts
|
|
10379
10605
|
var ArtifactType = /* @__PURE__ */ ((ArtifactType2) => {
|
|
10380
10606
|
ArtifactType2[ArtifactType2["ARTIFACT_TYPE_UNSPECIFIED"] = 0] = "ARTIFACT_TYPE_UNSPECIFIED";
|
|
@@ -10416,9 +10642,16 @@ function validateVote(vote) {
|
|
|
10416
10642
|
}
|
|
10417
10643
|
}
|
|
10418
10644
|
var NegotiationRoomClient = class {
|
|
10419
|
-
|
|
10420
|
-
|
|
10421
|
-
|
|
10645
|
+
store;
|
|
10646
|
+
/**
|
|
10647
|
+
* Create a new negotiation room client.
|
|
10648
|
+
*
|
|
10649
|
+
* @param options - Configuration options. If no store is provided,
|
|
10650
|
+
* uses the shared default in-memory store.
|
|
10651
|
+
*/
|
|
10652
|
+
constructor(options = {}) {
|
|
10653
|
+
this.store = options.store || getDefaultStore();
|
|
10654
|
+
}
|
|
10422
10655
|
/**
|
|
10423
10656
|
* Submit an artifact proposal for multi-agent review.
|
|
10424
10657
|
*
|
|
@@ -10446,19 +10679,8 @@ var NegotiationRoomClient = class {
|
|
|
10446
10679
|
* ```
|
|
10447
10680
|
*/
|
|
10448
10681
|
async submitProposal(proposal) {
|
|
10449
|
-
|
|
10450
|
-
|
|
10451
|
-
throw new NegotiationValidationError(
|
|
10452
|
-
`Proposal with artifact_id '${artifactId}' already exists`
|
|
10453
|
-
);
|
|
10454
|
-
}
|
|
10455
|
-
const proposalWithTimestamp = {
|
|
10456
|
-
...proposal,
|
|
10457
|
-
createdAt: proposal.createdAt || (/* @__PURE__ */ new Date()).toISOString()
|
|
10458
|
-
};
|
|
10459
|
-
this.proposals.set(artifactId, proposalWithTimestamp);
|
|
10460
|
-
this.votes.set(artifactId, []);
|
|
10461
|
-
return artifactId;
|
|
10682
|
+
await this.store.saveProposal(proposal);
|
|
10683
|
+
return proposal.artifactId;
|
|
10462
10684
|
}
|
|
10463
10685
|
/**
|
|
10464
10686
|
* Submit a critic's vote for an artifact.
|
|
@@ -10490,26 +10712,13 @@ var NegotiationRoomClient = class {
|
|
|
10490
10712
|
*/
|
|
10491
10713
|
async submitVote(vote) {
|
|
10492
10714
|
const artifactId = vote.artifactId;
|
|
10493
|
-
if (!this.
|
|
10715
|
+
if (!await this.store.hasProposal(artifactId)) {
|
|
10494
10716
|
throw new NegotiationValidationError(
|
|
10495
10717
|
`No proposal found for artifact_id '${artifactId}'`
|
|
10496
10718
|
);
|
|
10497
10719
|
}
|
|
10498
10720
|
validateVote(vote);
|
|
10499
|
-
|
|
10500
|
-
for (const existingVote of existingVotes) {
|
|
10501
|
-
if (existingVote.criticId === vote.criticId) {
|
|
10502
|
-
throw new NegotiationValidationError(
|
|
10503
|
-
`Critic '${vote.criticId}' has already voted for artifact '${artifactId}'`
|
|
10504
|
-
);
|
|
10505
|
-
}
|
|
10506
|
-
}
|
|
10507
|
-
const voteWithTimestamp = {
|
|
10508
|
-
...vote,
|
|
10509
|
-
votedAt: vote.votedAt || (/* @__PURE__ */ new Date()).toISOString()
|
|
10510
|
-
};
|
|
10511
|
-
existingVotes.push(voteWithTimestamp);
|
|
10512
|
-
this.votes.set(artifactId, existingVotes);
|
|
10721
|
+
await this.store.addVote(vote);
|
|
10513
10722
|
}
|
|
10514
10723
|
/**
|
|
10515
10724
|
* Retrieve all votes for a specific artifact.
|
|
@@ -10529,12 +10738,12 @@ var NegotiationRoomClient = class {
|
|
|
10529
10738
|
* ```
|
|
10530
10739
|
*/
|
|
10531
10740
|
async getVotes(artifactId) {
|
|
10532
|
-
if (!this.
|
|
10741
|
+
if (!await this.store.hasProposal(artifactId)) {
|
|
10533
10742
|
throw new NegotiationValidationError(
|
|
10534
10743
|
`No proposal found for artifact_id '${artifactId}'`
|
|
10535
10744
|
);
|
|
10536
10745
|
}
|
|
10537
|
-
return this.
|
|
10746
|
+
return this.store.getVotes(artifactId);
|
|
10538
10747
|
}
|
|
10539
10748
|
/**
|
|
10540
10749
|
* Retrieve the decision for a specific artifact if available.
|
|
@@ -10555,12 +10764,12 @@ var NegotiationRoomClient = class {
|
|
|
10555
10764
|
* ```
|
|
10556
10765
|
*/
|
|
10557
10766
|
async getDecision(artifactId) {
|
|
10558
|
-
if (!this.
|
|
10767
|
+
if (!await this.store.hasProposal(artifactId)) {
|
|
10559
10768
|
throw new NegotiationValidationError(
|
|
10560
10769
|
`No proposal found for artifact_id '${artifactId}'`
|
|
10561
10770
|
);
|
|
10562
10771
|
}
|
|
10563
|
-
return this.
|
|
10772
|
+
return this.store.getDecision(artifactId);
|
|
10564
10773
|
}
|
|
10565
10774
|
/**
|
|
10566
10775
|
* Store a decision for an artifact.
|
|
@@ -10591,21 +10800,12 @@ var NegotiationRoomClient = class {
|
|
|
10591
10800
|
*/
|
|
10592
10801
|
async storeDecision(decision) {
|
|
10593
10802
|
const artifactId = decision.artifactId;
|
|
10594
|
-
if (!this.
|
|
10803
|
+
if (!await this.store.hasProposal(artifactId)) {
|
|
10595
10804
|
throw new NegotiationValidationError(
|
|
10596
10805
|
`No proposal found for artifact_id '${artifactId}'`
|
|
10597
10806
|
);
|
|
10598
10807
|
}
|
|
10599
|
-
|
|
10600
|
-
throw new NegotiationValidationError(
|
|
10601
|
-
`Decision already exists for artifact_id '${artifactId}'`
|
|
10602
|
-
);
|
|
10603
|
-
}
|
|
10604
|
-
const decisionWithTimestamp = {
|
|
10605
|
-
...decision,
|
|
10606
|
-
decidedAt: decision.decidedAt || (/* @__PURE__ */ new Date()).toISOString()
|
|
10607
|
-
};
|
|
10608
|
-
this.decisions.set(artifactId, decisionWithTimestamp);
|
|
10808
|
+
await this.store.saveDecision(decision);
|
|
10609
10809
|
}
|
|
10610
10810
|
/**
|
|
10611
10811
|
* Wait for a decision to be made on an artifact.
|
|
@@ -10629,14 +10829,14 @@ var NegotiationRoomClient = class {
|
|
|
10629
10829
|
* ```
|
|
10630
10830
|
*/
|
|
10631
10831
|
async waitForDecision(artifactId, timeoutMs = 3e4, pollIntervalMs = 100) {
|
|
10632
|
-
if (!this.
|
|
10832
|
+
if (!await this.store.hasProposal(artifactId)) {
|
|
10633
10833
|
throw new NegotiationValidationError(
|
|
10634
10834
|
`No proposal found for artifact_id '${artifactId}'`
|
|
10635
10835
|
);
|
|
10636
10836
|
}
|
|
10637
10837
|
const startTime = Date.now();
|
|
10638
10838
|
while (Date.now() - startTime < timeoutMs) {
|
|
10639
|
-
const decision = await this.getDecision(artifactId);
|
|
10839
|
+
const decision = await this.store.getDecision(artifactId);
|
|
10640
10840
|
if (decision !== null) {
|
|
10641
10841
|
return decision;
|
|
10642
10842
|
}
|
|
@@ -10662,7 +10862,7 @@ var NegotiationRoomClient = class {
|
|
|
10662
10862
|
* ```
|
|
10663
10863
|
*/
|
|
10664
10864
|
async getProposal(artifactId) {
|
|
10665
|
-
return this.
|
|
10865
|
+
return this.store.getProposal(artifactId);
|
|
10666
10866
|
}
|
|
10667
10867
|
/**
|
|
10668
10868
|
* List all proposals, optionally filtered by negotiation room.
|
|
@@ -10677,13 +10877,7 @@ var NegotiationRoomClient = class {
|
|
|
10677
10877
|
* ```
|
|
10678
10878
|
*/
|
|
10679
10879
|
async listProposals(negotiationRoomId) {
|
|
10680
|
-
|
|
10681
|
-
if (negotiationRoomId === void 0) {
|
|
10682
|
-
return allProposals;
|
|
10683
|
-
}
|
|
10684
|
-
return allProposals.filter(
|
|
10685
|
-
(p) => p.negotiationRoomId === negotiationRoomId
|
|
10686
|
-
);
|
|
10880
|
+
return this.store.listProposals(negotiationRoomId);
|
|
10687
10881
|
}
|
|
10688
10882
|
};
|
|
10689
10883
|
function aggregateVotes(votes) {
|
|
@@ -11311,6 +11505,31 @@ var WorkflowClient = class {
|
|
|
11311
11505
|
instance.completedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
11312
11506
|
}
|
|
11313
11507
|
}
|
|
11508
|
+
/**
|
|
11509
|
+
* Resume a workflow by marking a node as completed and advancing dependents.
|
|
11510
|
+
*
|
|
11511
|
+
* Implements the ResumeWorkflow RPC (spec §17.7 MUST). Marks the specified
|
|
11512
|
+
* node as COMPLETED, updates workflow data if provided, then transitions
|
|
11513
|
+
* dependent nodes from PENDING to READY when all their dependencies are met.
|
|
11514
|
+
*
|
|
11515
|
+
* @param instanceId - The ID of the workflow instance
|
|
11516
|
+
* @param nodeId - The ID of the node to mark as completed
|
|
11517
|
+
* @param workflowData - Optional updated workflow data (JSON string)
|
|
11518
|
+
* @param metadata - Optional metadata for the resume operation
|
|
11519
|
+
* @returns The updated workflow instance
|
|
11520
|
+
* @throws WorkflowValidationError if the instance or node does not exist
|
|
11521
|
+
*/
|
|
11522
|
+
async resumeWorkflow(instanceId, nodeId, workflowData, metadata) {
|
|
11523
|
+
await this.updateNodeState(instanceId, nodeId, 4 /* COMPLETED */);
|
|
11524
|
+
if (workflowData !== void 0) {
|
|
11525
|
+
await this.updateWorkflowData(instanceId, workflowData);
|
|
11526
|
+
}
|
|
11527
|
+
if (metadata) {
|
|
11528
|
+
const instance = this.instances.get(instanceId);
|
|
11529
|
+
Object.assign(instance.metadata, metadata);
|
|
11530
|
+
}
|
|
11531
|
+
return this.getWorkflowStatus(instanceId);
|
|
11532
|
+
}
|
|
11314
11533
|
/**
|
|
11315
11534
|
* Update the shared workflow data.
|
|
11316
11535
|
*
|
|
@@ -11332,6 +11551,21 @@ var WorkflowClient = class {
|
|
|
11332
11551
|
|
|
11333
11552
|
// src/internal/envelope.ts
|
|
11334
11553
|
var import_node_crypto2 = __toESM(require("node:crypto"), 1);
|
|
11554
|
+
var MessageType = /* @__PURE__ */ ((MessageType2) => {
|
|
11555
|
+
MessageType2[MessageType2["MESSAGE_TYPE_UNSPECIFIED"] = 0] = "MESSAGE_TYPE_UNSPECIFIED";
|
|
11556
|
+
MessageType2[MessageType2["CONTROL"] = 1] = "CONTROL";
|
|
11557
|
+
MessageType2[MessageType2["DATA"] = 2] = "DATA";
|
|
11558
|
+
MessageType2[MessageType2["HEARTBEAT"] = 3] = "HEARTBEAT";
|
|
11559
|
+
MessageType2[MessageType2["NOTIFICATION"] = 4] = "NOTIFICATION";
|
|
11560
|
+
MessageType2[MessageType2["ACKNOWLEDGEMENT"] = 5] = "ACKNOWLEDGEMENT";
|
|
11561
|
+
MessageType2[MessageType2["HITL_INVOCATION"] = 6] = "HITL_INVOCATION";
|
|
11562
|
+
MessageType2[MessageType2["WORKTREE_CONTROL"] = 7] = "WORKTREE_CONTROL";
|
|
11563
|
+
MessageType2[MessageType2["NEGOTIATION"] = 8] = "NEGOTIATION";
|
|
11564
|
+
MessageType2[MessageType2["TOOL_CALL"] = 9] = "TOOL_CALL";
|
|
11565
|
+
MessageType2[MessageType2["TOOL_RESULT"] = 10] = "TOOL_RESULT";
|
|
11566
|
+
MessageType2[MessageType2["TOOL_ERROR"] = 11] = "TOOL_ERROR";
|
|
11567
|
+
return MessageType2;
|
|
11568
|
+
})(MessageType || {});
|
|
11335
11569
|
function nowTimestamp(date = /* @__PURE__ */ new Date()) {
|
|
11336
11570
|
const ms = date.getTime();
|
|
11337
11571
|
const seconds = Math.floor(ms / 1e3);
|
|
@@ -11339,7 +11573,15 @@ function nowTimestamp(date = /* @__PURE__ */ new Date()) {
|
|
|
11339
11573
|
return { seconds, nanos };
|
|
11340
11574
|
}
|
|
11341
11575
|
function nowHlcStub(date = /* @__PURE__ */ new Date()) {
|
|
11342
|
-
|
|
11576
|
+
const wallUs = date.getTime() * 1e3;
|
|
11577
|
+
let node = "unknown";
|
|
11578
|
+
try {
|
|
11579
|
+
const os = require("node:os");
|
|
11580
|
+
node = os.hostname() || "unknown";
|
|
11581
|
+
} catch {
|
|
11582
|
+
node = "browser";
|
|
11583
|
+
}
|
|
11584
|
+
return `HLC:${wallUs}:0:${node}`;
|
|
11343
11585
|
}
|
|
11344
11586
|
function uuidv42() {
|
|
11345
11587
|
if (typeof import_node_crypto2.default.randomUUID === "function") {
|
|
@@ -11375,7 +11617,12 @@ function buildEnvelope(input) {
|
|
|
11375
11617
|
hlc_timestamp,
|
|
11376
11618
|
// Always set hlc_timestamp (aligns with Python/Rust)
|
|
11377
11619
|
ttl_ms: input.ttl_ms,
|
|
11378
|
-
timestamp: ts
|
|
11620
|
+
timestamp: ts,
|
|
11621
|
+
state: input.state ?? 1,
|
|
11622
|
+
// EnvelopeState.CREATED
|
|
11623
|
+
effective_policy_id: input.effective_policy_id ?? "",
|
|
11624
|
+
audit_proof: input.audit_proof ?? new Uint8Array(0),
|
|
11625
|
+
audit_policy_id: input.audit_policy_id ?? ""
|
|
11379
11626
|
};
|
|
11380
11627
|
if (hasPayload) {
|
|
11381
11628
|
const payload = input.payload instanceof Uint8Array ? input.payload : new Uint8Array(input.payload);
|
|
@@ -11389,25 +11636,141 @@ function buildEnvelope(input) {
|
|
|
11389
11636
|
}
|
|
11390
11637
|
|
|
11391
11638
|
// src/internal/worktreeState.ts
|
|
11639
|
+
var VALID_WORKTREE_TRANSITIONS = {
|
|
11640
|
+
UNBOUND: ["BOUND_HOME", "BIND_FAILED"],
|
|
11641
|
+
BOUND_HOME: ["SWITCH_PENDING", "UNBOUND"],
|
|
11642
|
+
SWITCH_PENDING: ["BOUND_NON_HOME", "BOUND_HOME"],
|
|
11643
|
+
// approve or reject
|
|
11644
|
+
BOUND_NON_HOME: ["BOUND_HOME", "UNBOUND"],
|
|
11645
|
+
// TTL expired/revoke, or unbind
|
|
11646
|
+
BIND_FAILED: ["UNBOUND", "BOUND_HOME"]
|
|
11647
|
+
// retry reset or successful retry
|
|
11648
|
+
};
|
|
11649
|
+
function isValidWorktreeTransition(from, to) {
|
|
11650
|
+
return VALID_WORKTREE_TRANSITIONS[from]?.includes(to) ?? false;
|
|
11651
|
+
}
|
|
11652
|
+
var WorktreeTransitionError = class extends Error {
|
|
11653
|
+
fromState;
|
|
11654
|
+
toState;
|
|
11655
|
+
constructor(from, to) {
|
|
11656
|
+
super(`Invalid worktree state transition from ${from} to ${to}`);
|
|
11657
|
+
this.name = "WorktreeTransitionError";
|
|
11658
|
+
this.fromState = from;
|
|
11659
|
+
this.toState = to;
|
|
11660
|
+
}
|
|
11661
|
+
};
|
|
11392
11662
|
var PersistentWorktreeState = class {
|
|
11393
11663
|
state = "UNBOUND";
|
|
11394
11664
|
repoId;
|
|
11395
11665
|
worktreeId;
|
|
11666
|
+
homeRepoId;
|
|
11667
|
+
homeWorktreeId;
|
|
11668
|
+
switchTtlMs;
|
|
11669
|
+
switchTimer;
|
|
11670
|
+
/**
|
|
11671
|
+
* Transition to a new state with validation.
|
|
11672
|
+
* @throws WorktreeTransitionError if transition is invalid
|
|
11673
|
+
*/
|
|
11674
|
+
transitionTo(newState) {
|
|
11675
|
+
if (!isValidWorktreeTransition(this.state, newState)) {
|
|
11676
|
+
throw new WorktreeTransitionError(this.state, newState);
|
|
11677
|
+
}
|
|
11678
|
+
this.state = newState;
|
|
11679
|
+
}
|
|
11680
|
+
/**
|
|
11681
|
+
* Bind to a home worktree (UNBOUND -> BOUND_HOME or BIND_FAILED -> BOUND_HOME).
|
|
11682
|
+
*/
|
|
11396
11683
|
bind(repoId, worktreeId) {
|
|
11684
|
+
this.transitionTo("BOUND_HOME");
|
|
11397
11685
|
this.repoId = repoId;
|
|
11398
11686
|
this.worktreeId = worktreeId;
|
|
11399
|
-
this.
|
|
11687
|
+
this.homeRepoId = repoId;
|
|
11688
|
+
this.homeWorktreeId = worktreeId;
|
|
11689
|
+
}
|
|
11690
|
+
/**
|
|
11691
|
+
* Handle bind failure (UNBOUND -> BIND_FAILED).
|
|
11692
|
+
*/
|
|
11693
|
+
bindFailed() {
|
|
11694
|
+
this.transitionTo("BIND_FAILED");
|
|
11400
11695
|
}
|
|
11696
|
+
/**
|
|
11697
|
+
* Unbind from current worktree.
|
|
11698
|
+
*/
|
|
11401
11699
|
unbind() {
|
|
11700
|
+
this.clearSwitchTimer();
|
|
11701
|
+
this.transitionTo("UNBOUND");
|
|
11402
11702
|
this.repoId = void 0;
|
|
11403
11703
|
this.worktreeId = void 0;
|
|
11404
|
-
|
|
11704
|
+
}
|
|
11705
|
+
/**
|
|
11706
|
+
* Request switch to a non-home worktree (BOUND_HOME -> SWITCH_PENDING).
|
|
11707
|
+
* Requires approval or rejection before taking effect.
|
|
11708
|
+
*/
|
|
11709
|
+
requestSwitch(targetRepoId, targetWorktreeId) {
|
|
11710
|
+
this.transitionTo("SWITCH_PENDING");
|
|
11711
|
+
this._pendingRepoId = targetRepoId;
|
|
11712
|
+
this._pendingWorktreeId = targetWorktreeId;
|
|
11713
|
+
}
|
|
11714
|
+
/**
|
|
11715
|
+
* Approve a pending switch (SWITCH_PENDING -> BOUND_NON_HOME).
|
|
11716
|
+
* @param ttlMs - Time-to-live in milliseconds before auto-reverting to BOUND_HOME
|
|
11717
|
+
*/
|
|
11718
|
+
approveSwitch(ttlMs = 3e5) {
|
|
11719
|
+
this.transitionTo("BOUND_NON_HOME");
|
|
11720
|
+
this.repoId = this._pendingRepoId;
|
|
11721
|
+
this.worktreeId = this._pendingWorktreeId;
|
|
11722
|
+
this.switchTtlMs = ttlMs;
|
|
11723
|
+
this.clearSwitchTimer();
|
|
11724
|
+
this.switchTimer = setTimeout(() => {
|
|
11725
|
+
this.revertToHome();
|
|
11726
|
+
}, ttlMs);
|
|
11727
|
+
}
|
|
11728
|
+
/**
|
|
11729
|
+
* Reject a pending switch (SWITCH_PENDING -> BOUND_HOME).
|
|
11730
|
+
*/
|
|
11731
|
+
rejectSwitch() {
|
|
11732
|
+
this.transitionTo("BOUND_HOME");
|
|
11733
|
+
this.repoId = this.homeRepoId;
|
|
11734
|
+
this.worktreeId = this.homeWorktreeId;
|
|
11735
|
+
delete this._pendingRepoId;
|
|
11736
|
+
delete this._pendingWorktreeId;
|
|
11737
|
+
}
|
|
11738
|
+
/**
|
|
11739
|
+
* Revert from non-home to home worktree (BOUND_NON_HOME -> BOUND_HOME).
|
|
11740
|
+
* Called on TTL expiry or explicit revoke.
|
|
11741
|
+
*/
|
|
11742
|
+
revertToHome() {
|
|
11743
|
+
this.clearSwitchTimer();
|
|
11744
|
+
if (this.state === "BOUND_NON_HOME") {
|
|
11745
|
+
this.transitionTo("BOUND_HOME");
|
|
11746
|
+
this.repoId = this.homeRepoId;
|
|
11747
|
+
this.worktreeId = this.homeWorktreeId;
|
|
11748
|
+
}
|
|
11749
|
+
}
|
|
11750
|
+
/**
|
|
11751
|
+
* Reset from BIND_FAILED to UNBOUND for retry.
|
|
11752
|
+
*/
|
|
11753
|
+
resetFromFailed() {
|
|
11754
|
+
this.transitionTo("UNBOUND");
|
|
11755
|
+
}
|
|
11756
|
+
clearSwitchTimer() {
|
|
11757
|
+
if (this.switchTimer) {
|
|
11758
|
+
clearTimeout(this.switchTimer);
|
|
11759
|
+
this.switchTimer = void 0;
|
|
11760
|
+
}
|
|
11405
11761
|
}
|
|
11406
11762
|
setState(state) {
|
|
11407
11763
|
this.state = state;
|
|
11408
11764
|
}
|
|
11409
11765
|
current() {
|
|
11410
|
-
return {
|
|
11766
|
+
return {
|
|
11767
|
+
state: this.state,
|
|
11768
|
+
repo_id: this.repoId,
|
|
11769
|
+
worktree_id: this.worktreeId,
|
|
11770
|
+
home_repo_id: this.homeRepoId,
|
|
11771
|
+
home_worktree_id: this.homeWorktreeId,
|
|
11772
|
+
switch_ttl_ms: this.switchTtlMs
|
|
11773
|
+
};
|
|
11411
11774
|
}
|
|
11412
11775
|
};
|
|
11413
11776
|
|
|
@@ -11469,16 +11832,6 @@ var ActivityBuffer = class {
|
|
|
11469
11832
|
};
|
|
11470
11833
|
|
|
11471
11834
|
// src/internal/runtime/ackLifecycle.ts
|
|
11472
|
-
var AckStage = /* @__PURE__ */ ((AckStage2) => {
|
|
11473
|
-
AckStage2[AckStage2["ACK_STAGE_UNSPECIFIED"] = 0] = "ACK_STAGE_UNSPECIFIED";
|
|
11474
|
-
AckStage2[AckStage2["RECEIVED"] = 1] = "RECEIVED";
|
|
11475
|
-
AckStage2[AckStage2["READ"] = 2] = "READ";
|
|
11476
|
-
AckStage2[AckStage2["FULFILLED"] = 3] = "FULFILLED";
|
|
11477
|
-
AckStage2[AckStage2["REJECTED"] = 4] = "REJECTED";
|
|
11478
|
-
AckStage2[AckStage2["FAILED"] = 5] = "FAILED";
|
|
11479
|
-
AckStage2[AckStage2["TIMED_OUT"] = 6] = "TIMED_OUT";
|
|
11480
|
-
return AckStage2;
|
|
11481
|
-
})(AckStage || {});
|
|
11482
11835
|
var ACKLifecycleManager = class {
|
|
11483
11836
|
acks = /* @__PURE__ */ new Map();
|
|
11484
11837
|
mark(messageId, stage, note, errorCode) {
|
|
@@ -11515,21 +11868,6 @@ var ACKLifecycleManager = class {
|
|
|
11515
11868
|
};
|
|
11516
11869
|
|
|
11517
11870
|
// src/internal/runtime/messageProcessor.ts
|
|
11518
|
-
var MessageType = /* @__PURE__ */ ((MessageType3) => {
|
|
11519
|
-
MessageType3[MessageType3["MESSAGE_TYPE_UNSPECIFIED"] = 0] = "MESSAGE_TYPE_UNSPECIFIED";
|
|
11520
|
-
MessageType3[MessageType3["CONTROL"] = 1] = "CONTROL";
|
|
11521
|
-
MessageType3[MessageType3["DATA"] = 2] = "DATA";
|
|
11522
|
-
MessageType3[MessageType3["HEARTBEAT"] = 3] = "HEARTBEAT";
|
|
11523
|
-
MessageType3[MessageType3["NOTIFICATION"] = 4] = "NOTIFICATION";
|
|
11524
|
-
MessageType3[MessageType3["ACKNOWLEDGEMENT"] = 5] = "ACKNOWLEDGEMENT";
|
|
11525
|
-
MessageType3[MessageType3["HITL_INVOCATION"] = 6] = "HITL_INVOCATION";
|
|
11526
|
-
MessageType3[MessageType3["WORKTREE_CONTROL"] = 7] = "WORKTREE_CONTROL";
|
|
11527
|
-
MessageType3[MessageType3["NEGOTIATION"] = 8] = "NEGOTIATION";
|
|
11528
|
-
MessageType3[MessageType3["TOOL_CALL"] = 9] = "TOOL_CALL";
|
|
11529
|
-
MessageType3[MessageType3["TOOL_RESULT"] = 10] = "TOOL_RESULT";
|
|
11530
|
-
MessageType3[MessageType3["TOOL_ERROR"] = 11] = "TOOL_ERROR";
|
|
11531
|
-
return MessageType3;
|
|
11532
|
-
})(MessageType || {});
|
|
11533
11871
|
var MessageProcessor = class {
|
|
11534
11872
|
handlers = /* @__PURE__ */ new Map();
|
|
11535
11873
|
defaultHandler;
|
|
@@ -12649,7 +12987,7 @@ var AgentState = /* @__PURE__ */ ((AgentState2) => {
|
|
|
12649
12987
|
AgentState2[AgentState2["RECOVERING"] = 12] = "RECOVERING";
|
|
12650
12988
|
return AgentState2;
|
|
12651
12989
|
})(AgentState || {});
|
|
12652
|
-
var
|
|
12990
|
+
var StateTransitionError2 = class extends Error {
|
|
12653
12991
|
fromState;
|
|
12654
12992
|
toState;
|
|
12655
12993
|
constructor(fromState, toState) {
|
|
@@ -12662,8 +13000,8 @@ var StateTransitionError = class extends Error {
|
|
|
12662
13000
|
}
|
|
12663
13001
|
};
|
|
12664
13002
|
var VALID_TRANSITIONS = /* @__PURE__ */ new Map([
|
|
12665
|
-
// INITIALIZING -> RUNNABLE
|
|
12666
|
-
[1 /* INITIALIZING */, /* @__PURE__ */ new Set([2 /* RUNNABLE */])],
|
|
13003
|
+
// INITIALIZING -> RUNNABLE, FAILED (init timeout per spec s8.2)
|
|
13004
|
+
[1 /* INITIALIZING */, /* @__PURE__ */ new Set([2 /* RUNNABLE */, 10 /* FAILED */])],
|
|
12667
13005
|
// RUNNABLE -> SCHEDULED
|
|
12668
13006
|
[2 /* RUNNABLE */, /* @__PURE__ */ new Set([3 /* SCHEDULED */])],
|
|
12669
13007
|
// SCHEDULED -> RUNNING
|
|
@@ -12687,8 +13025,8 @@ var VALID_TRANSITIONS = /* @__PURE__ */ new Map([
|
|
|
12687
13025
|
6 /* WAITING_RESOURCES */,
|
|
12688
13026
|
/* @__PURE__ */ new Set([4 /* RUNNING */, 10 /* FAILED */])
|
|
12689
13027
|
],
|
|
12690
|
-
// SUSPENDED -> RESUMED
|
|
12691
|
-
[7 /* SUSPENDED */, /* @__PURE__ */ new Set([8 /* RESUMED */])],
|
|
13028
|
+
// SUSPENDED -> RESUMED, FAILED (suspension timeout per spec s8.3)
|
|
13029
|
+
[7 /* SUSPENDED */, /* @__PURE__ */ new Set([8 /* RESUMED */, 10 /* FAILED */])],
|
|
12692
13030
|
// RESUMED -> RUNNING
|
|
12693
13031
|
[8 /* RESUMED */, /* @__PURE__ */ new Set([4 /* RUNNING */])],
|
|
12694
13032
|
// COMPLETED -> RUNNABLE
|
|
@@ -12697,10 +13035,10 @@ var VALID_TRANSITIONS = /* @__PURE__ */ new Map([
|
|
|
12697
13035
|
[10 /* FAILED */, /* @__PURE__ */ new Set([12 /* RECOVERING */])],
|
|
12698
13036
|
// SHUTTING_DOWN -> FAILED (agent_shutdown_timeout)
|
|
12699
13037
|
[11 /* SHUTTING_DOWN */, /* @__PURE__ */ new Set([10 /* FAILED */])],
|
|
12700
|
-
// RECOVERING -> RUNNABLE, SHUTTING_DOWN (recovery abort)
|
|
13038
|
+
// RECOVERING -> RUNNABLE, SHUTTING_DOWN (recovery abort), FAILED (recovery timeout per spec s8.3)
|
|
12701
13039
|
[
|
|
12702
13040
|
12 /* RECOVERING */,
|
|
12703
|
-
/* @__PURE__ */ new Set([2 /* RUNNABLE */, 11 /* SHUTTING_DOWN */])
|
|
13041
|
+
/* @__PURE__ */ new Set([2 /* RUNNABLE */, 11 /* SHUTTING_DOWN */, 10 /* FAILED */])
|
|
12704
13042
|
]
|
|
12705
13043
|
]);
|
|
12706
13044
|
function isValidTransition(fromState, toState) {
|
|
@@ -12752,7 +13090,7 @@ var AgentStateMachine = class {
|
|
|
12752
13090
|
*/
|
|
12753
13091
|
async initialize() {
|
|
12754
13092
|
if (this.state !== 0 /* AGENT_STATE_UNSPECIFIED */) {
|
|
12755
|
-
throw new
|
|
13093
|
+
throw new StateTransitionError2(this.state, 1 /* INITIALIZING */);
|
|
12756
13094
|
}
|
|
12757
13095
|
await this.transitionTo(1 /* INITIALIZING */);
|
|
12758
13096
|
}
|
|
@@ -12769,7 +13107,7 @@ var AgentStateMachine = class {
|
|
|
12769
13107
|
return;
|
|
12770
13108
|
}
|
|
12771
13109
|
if (!isValidTransition(this.state, toState)) {
|
|
12772
|
-
throw new
|
|
13110
|
+
throw new StateTransitionError2(this.state, toState);
|
|
12773
13111
|
}
|
|
12774
13112
|
await this.doTransition(toState, context);
|
|
12775
13113
|
}
|
|
@@ -12933,7 +13271,8 @@ function computeIdempotencyToken(input) {
|
|
|
12933
13271
|
h.update(input.operation);
|
|
12934
13272
|
h.update("\n");
|
|
12935
13273
|
h.update(Buffer.from(input.canonical_bytes));
|
|
12936
|
-
|
|
13274
|
+
const hash16 = h.digest("hex").slice(0, 16);
|
|
13275
|
+
return `${input.producer_id}:${input.operation}:${hash16}`;
|
|
12937
13276
|
}
|
|
12938
13277
|
|
|
12939
13278
|
// src/runtime/persistenceAdapter.ts
|
|
@@ -13050,6 +13389,669 @@ function normalizeReportPaths(report) {
|
|
|
13050
13389
|
return report;
|
|
13051
13390
|
}
|
|
13052
13391
|
|
|
13392
|
+
// src/constants/index.ts
|
|
13393
|
+
var CommunicationClass = /* @__PURE__ */ ((CommunicationClass2) => {
|
|
13394
|
+
CommunicationClass2[CommunicationClass2["COMM_CLASS_UNSPECIFIED"] = 0] = "COMM_CLASS_UNSPECIFIED";
|
|
13395
|
+
CommunicationClass2[CommunicationClass2["PRIVILEGED"] = 1] = "PRIVILEGED";
|
|
13396
|
+
CommunicationClass2[CommunicationClass2["STANDARD"] = 2] = "STANDARD";
|
|
13397
|
+
CommunicationClass2[CommunicationClass2["BULK"] = 3] = "BULK";
|
|
13398
|
+
return CommunicationClass2;
|
|
13399
|
+
})(CommunicationClass || {});
|
|
13400
|
+
var DebateIntensity = /* @__PURE__ */ ((DebateIntensity2) => {
|
|
13401
|
+
DebateIntensity2[DebateIntensity2["DEBATE_INTENSITY_UNSPECIFIED"] = 0] = "DEBATE_INTENSITY_UNSPECIFIED";
|
|
13402
|
+
DebateIntensity2[DebateIntensity2["LOWEST"] = 1] = "LOWEST";
|
|
13403
|
+
DebateIntensity2[DebateIntensity2["LOW"] = 2] = "LOW";
|
|
13404
|
+
DebateIntensity2[DebateIntensity2["MEDIUM"] = 3] = "MEDIUM";
|
|
13405
|
+
DebateIntensity2[DebateIntensity2["HIGH"] = 4] = "HIGH";
|
|
13406
|
+
DebateIntensity2[DebateIntensity2["HIGHEST"] = 5] = "HIGHEST";
|
|
13407
|
+
return DebateIntensity2;
|
|
13408
|
+
})(DebateIntensity || {});
|
|
13409
|
+
var HitlReasonType = /* @__PURE__ */ ((HitlReasonType2) => {
|
|
13410
|
+
HitlReasonType2[HitlReasonType2["HITL_REASON_UNSPECIFIED"] = 0] = "HITL_REASON_UNSPECIFIED";
|
|
13411
|
+
HitlReasonType2[HitlReasonType2["CONFLICT"] = 1] = "CONFLICT";
|
|
13412
|
+
HitlReasonType2[HitlReasonType2["SECURITY_APPROVAL"] = 2] = "SECURITY_APPROVAL";
|
|
13413
|
+
HitlReasonType2[HitlReasonType2["TASK_ESCALATION"] = 3] = "TASK_ESCALATION";
|
|
13414
|
+
HitlReasonType2[HitlReasonType2["MANUAL_OVERRIDE"] = 4] = "MANUAL_OVERRIDE";
|
|
13415
|
+
HitlReasonType2[HitlReasonType2["WORKTREE_OVERRIDE"] = 5] = "WORKTREE_OVERRIDE";
|
|
13416
|
+
HitlReasonType2[HitlReasonType2["DEBATE_DEADLOCK"] = 6] = "DEBATE_DEADLOCK";
|
|
13417
|
+
HitlReasonType2[HitlReasonType2["TOOL_PRIVILEGE_ESCALATION"] = 7] = "TOOL_PRIVILEGE_ESCALATION";
|
|
13418
|
+
HitlReasonType2[HitlReasonType2["CONNECTOR_APPROVAL"] = 8] = "CONNECTOR_APPROVAL";
|
|
13419
|
+
return HitlReasonType2;
|
|
13420
|
+
})(HitlReasonType || {});
|
|
13421
|
+
var AckStage2 = /* @__PURE__ */ ((AckStage3) => {
|
|
13422
|
+
AckStage3[AckStage3["ACK_STAGE_UNSPECIFIED"] = 0] = "ACK_STAGE_UNSPECIFIED";
|
|
13423
|
+
AckStage3[AckStage3["RECEIVED"] = 1] = "RECEIVED";
|
|
13424
|
+
AckStage3[AckStage3["READ"] = 2] = "READ";
|
|
13425
|
+
AckStage3[AckStage3["FULFILLED"] = 3] = "FULFILLED";
|
|
13426
|
+
AckStage3[AckStage3["REJECTED"] = 4] = "REJECTED";
|
|
13427
|
+
AckStage3[AckStage3["FAILED"] = 5] = "FAILED";
|
|
13428
|
+
AckStage3[AckStage3["TIMED_OUT"] = 6] = "TIMED_OUT";
|
|
13429
|
+
return AckStage3;
|
|
13430
|
+
})(AckStage2 || {});
|
|
13431
|
+
var EnvelopeState = /* @__PURE__ */ ((EnvelopeState3) => {
|
|
13432
|
+
EnvelopeState3[EnvelopeState3["ENVELOPE_STATE_UNSPECIFIED"] = 0] = "ENVELOPE_STATE_UNSPECIFIED";
|
|
13433
|
+
EnvelopeState3[EnvelopeState3["SENT"] = 1] = "SENT";
|
|
13434
|
+
EnvelopeState3[EnvelopeState3["RECEIVED"] = 2] = "RECEIVED";
|
|
13435
|
+
EnvelopeState3[EnvelopeState3["READ"] = 3] = "READ";
|
|
13436
|
+
EnvelopeState3[EnvelopeState3["FULFILLED"] = 4] = "FULFILLED";
|
|
13437
|
+
EnvelopeState3[EnvelopeState3["REJECTED"] = 5] = "REJECTED";
|
|
13438
|
+
EnvelopeState3[EnvelopeState3["FAILED"] = 6] = "FAILED";
|
|
13439
|
+
EnvelopeState3[EnvelopeState3["TIMED_OUT"] = 7] = "TIMED_OUT";
|
|
13440
|
+
return EnvelopeState3;
|
|
13441
|
+
})(EnvelopeState || {});
|
|
13442
|
+
var WorktreeStateEnum = /* @__PURE__ */ ((WorktreeStateEnum2) => {
|
|
13443
|
+
WorktreeStateEnum2[WorktreeStateEnum2["WORKTREE_STATE_UNSPECIFIED"] = 0] = "WORKTREE_STATE_UNSPECIFIED";
|
|
13444
|
+
WorktreeStateEnum2[WorktreeStateEnum2["UNBOUND"] = 1] = "UNBOUND";
|
|
13445
|
+
WorktreeStateEnum2[WorktreeStateEnum2["BOUND_HOME"] = 2] = "BOUND_HOME";
|
|
13446
|
+
WorktreeStateEnum2[WorktreeStateEnum2["SWITCH_PENDING"] = 3] = "SWITCH_PENDING";
|
|
13447
|
+
WorktreeStateEnum2[WorktreeStateEnum2["BOUND_NON_HOME"] = 4] = "BOUND_NON_HOME";
|
|
13448
|
+
WorktreeStateEnum2[WorktreeStateEnum2["BIND_FAILED"] = 5] = "BIND_FAILED";
|
|
13449
|
+
return WorktreeStateEnum2;
|
|
13450
|
+
})(WorktreeStateEnum || {});
|
|
13451
|
+
var DEFAULT_ACK_TIMEOUT_MS = 1e4;
|
|
13452
|
+
var DEDUP_WINDOW_S = 3600;
|
|
13453
|
+
function isTerminalEnvelopeState(state) {
|
|
13454
|
+
return state === 4 /* FULFILLED */ || state === 5 /* REJECTED */ || state === 6 /* FAILED */ || state === 7 /* TIMED_OUT */;
|
|
13455
|
+
}
|
|
13456
|
+
function updateEnvelopeState(envelope, newState) {
|
|
13457
|
+
envelope.state = newState;
|
|
13458
|
+
return envelope;
|
|
13459
|
+
}
|
|
13460
|
+
|
|
13461
|
+
// src/audit.ts
|
|
13462
|
+
var import_node_crypto4 = __toESM(require("node:crypto"), 1);
|
|
13463
|
+
function uuidv43() {
|
|
13464
|
+
if (typeof import_node_crypto4.default.randomUUID === "function") {
|
|
13465
|
+
return import_node_crypto4.default.randomUUID();
|
|
13466
|
+
}
|
|
13467
|
+
const buf = import_node_crypto4.default.randomBytes(16);
|
|
13468
|
+
buf[6] = buf[6] & 15 | 64;
|
|
13469
|
+
buf[8] = buf[8] & 63 | 128;
|
|
13470
|
+
const hex = [...buf].map((b) => b.toString(16).padStart(2, "0"));
|
|
13471
|
+
return hex.slice(0, 4).join("") + "-" + hex.slice(4, 6).join("") + "-" + hex.slice(6, 8).join("") + "-" + hex.slice(8, 10).join("") + "-" + hex.slice(10, 16).join("");
|
|
13472
|
+
}
|
|
13473
|
+
function computeEnvelopeHash(envelope) {
|
|
13474
|
+
const envelopeCopy = { ...envelope };
|
|
13475
|
+
const payload = envelopeCopy.payload;
|
|
13476
|
+
const audit_proof = envelopeCopy.audit_proof;
|
|
13477
|
+
delete envelopeCopy.payload;
|
|
13478
|
+
delete envelopeCopy.audit_proof;
|
|
13479
|
+
const envelopeJson = JSON.stringify(envelopeCopy, Object.keys(envelopeCopy).sort());
|
|
13480
|
+
const hasher = import_node_crypto4.default.createHash("sha256");
|
|
13481
|
+
hasher.update(envelopeJson, "utf-8");
|
|
13482
|
+
if (payload) {
|
|
13483
|
+
if (payload instanceof Uint8Array) {
|
|
13484
|
+
hasher.update(payload);
|
|
13485
|
+
} else if (typeof payload === "string") {
|
|
13486
|
+
hasher.update(payload, "utf-8");
|
|
13487
|
+
}
|
|
13488
|
+
}
|
|
13489
|
+
if (audit_proof) {
|
|
13490
|
+
if (audit_proof instanceof Uint8Array) {
|
|
13491
|
+
hasher.update(audit_proof);
|
|
13492
|
+
} else if (typeof audit_proof === "string") {
|
|
13493
|
+
hasher.update(audit_proof, "utf-8");
|
|
13494
|
+
}
|
|
13495
|
+
}
|
|
13496
|
+
return hasher.digest("hex");
|
|
13497
|
+
}
|
|
13498
|
+
function createSimpleProof(envelope, actor_id) {
|
|
13499
|
+
const envelopeHash = computeEnvelopeHash(envelope);
|
|
13500
|
+
const timestamp = nowHlcStub();
|
|
13501
|
+
const proofInput = `${envelopeHash}:${actor_id}:${timestamp}`;
|
|
13502
|
+
const proofHash = import_node_crypto4.default.createHash("sha256").update(proofInput, "utf-8").digest();
|
|
13503
|
+
return {
|
|
13504
|
+
proof_id: uuidv43(),
|
|
13505
|
+
proof_type: "simple_hash",
|
|
13506
|
+
proof_data: new Uint8Array(proofHash),
|
|
13507
|
+
created_at: timestamp,
|
|
13508
|
+
verified: false
|
|
13509
|
+
};
|
|
13510
|
+
}
|
|
13511
|
+
function verifyAuditProof(envelope, proof) {
|
|
13512
|
+
if (proof.proof_type === "noop") {
|
|
13513
|
+
return true;
|
|
13514
|
+
}
|
|
13515
|
+
if (proof.proof_type === "simple_hash") {
|
|
13516
|
+
if (proof.proof_data.length === 0) {
|
|
13517
|
+
return false;
|
|
13518
|
+
}
|
|
13519
|
+
const envelopeHash = computeEnvelopeHash(envelope);
|
|
13520
|
+
if (proof.proof_data.length !== 32) {
|
|
13521
|
+
return false;
|
|
13522
|
+
}
|
|
13523
|
+
return true;
|
|
13524
|
+
}
|
|
13525
|
+
return false;
|
|
13526
|
+
}
|
|
13527
|
+
var NoOpAuditor = class {
|
|
13528
|
+
/**
|
|
13529
|
+
* Create a minimal no-op proof.
|
|
13530
|
+
*
|
|
13531
|
+
* @param envelope - The envelope (ignored)
|
|
13532
|
+
* @param action - The action (ignored)
|
|
13533
|
+
* @returns A minimal no-op proof
|
|
13534
|
+
*/
|
|
13535
|
+
createProof(envelope, action) {
|
|
13536
|
+
return {
|
|
13537
|
+
proof_id: uuidv43(),
|
|
13538
|
+
proof_type: "noop",
|
|
13539
|
+
proof_data: new Uint8Array(0),
|
|
13540
|
+
created_at: nowHlcStub(),
|
|
13541
|
+
verified: true
|
|
13542
|
+
};
|
|
13543
|
+
}
|
|
13544
|
+
/**
|
|
13545
|
+
* Always returns true for no-op proofs.
|
|
13546
|
+
*
|
|
13547
|
+
* @param proof - The proof (ignored)
|
|
13548
|
+
* @returns Always true
|
|
13549
|
+
*/
|
|
13550
|
+
verifyProof(proof) {
|
|
13551
|
+
return true;
|
|
13552
|
+
}
|
|
13553
|
+
/**
|
|
13554
|
+
* Create a minimal audit record without storing it.
|
|
13555
|
+
*
|
|
13556
|
+
* @param envelope - The envelope being audited
|
|
13557
|
+
* @param action - The action being performed
|
|
13558
|
+
* @param proof - Optional proof to attach
|
|
13559
|
+
* @returns A minimal audit record
|
|
13560
|
+
*/
|
|
13561
|
+
record(envelope, action, proof) {
|
|
13562
|
+
return {
|
|
13563
|
+
record_id: uuidv43(),
|
|
13564
|
+
envelope_id: envelope.message_id ?? "unknown",
|
|
13565
|
+
action,
|
|
13566
|
+
actor_id: envelope.producer_id ?? "unknown",
|
|
13567
|
+
timestamp: nowHlcStub(),
|
|
13568
|
+
proof
|
|
13569
|
+
};
|
|
13570
|
+
}
|
|
13571
|
+
/**
|
|
13572
|
+
* Always returns empty array.
|
|
13573
|
+
*
|
|
13574
|
+
* @param envelope_id - The envelope ID (ignored)
|
|
13575
|
+
* @returns Empty array
|
|
13576
|
+
*/
|
|
13577
|
+
query(envelope_id) {
|
|
13578
|
+
return [];
|
|
13579
|
+
}
|
|
13580
|
+
};
|
|
13581
|
+
var InMemoryAuditor = class {
|
|
13582
|
+
_records;
|
|
13583
|
+
/**
|
|
13584
|
+
* Initialize with empty record storage.
|
|
13585
|
+
*/
|
|
13586
|
+
constructor() {
|
|
13587
|
+
this._records = /* @__PURE__ */ new Map();
|
|
13588
|
+
}
|
|
13589
|
+
/**
|
|
13590
|
+
* Create a simple hash-based proof.
|
|
13591
|
+
*
|
|
13592
|
+
* @param envelope - The envelope to create proof for
|
|
13593
|
+
* @param action - The action being performed
|
|
13594
|
+
* @returns A simple hash-based proof
|
|
13595
|
+
*/
|
|
13596
|
+
createProof(envelope, action) {
|
|
13597
|
+
return createSimpleProof(envelope, envelope.producer_id ?? "unknown");
|
|
13598
|
+
}
|
|
13599
|
+
/**
|
|
13600
|
+
* Verify a proof using the verification module.
|
|
13601
|
+
*
|
|
13602
|
+
* @param proof - The proof to verify
|
|
13603
|
+
* @returns True if proof is valid, false otherwise
|
|
13604
|
+
*/
|
|
13605
|
+
verifyProof(proof) {
|
|
13606
|
+
if (proof.proof_type === "noop") {
|
|
13607
|
+
return true;
|
|
13608
|
+
}
|
|
13609
|
+
if (proof.proof_type === "simple_hash") {
|
|
13610
|
+
return proof.proof_data.length > 0;
|
|
13611
|
+
}
|
|
13612
|
+
return false;
|
|
13613
|
+
}
|
|
13614
|
+
/**
|
|
13615
|
+
* Create and store an audit record.
|
|
13616
|
+
*
|
|
13617
|
+
* @param envelope - The envelope being audited
|
|
13618
|
+
* @param action - The action being performed
|
|
13619
|
+
* @param proof - Optional proof to attach
|
|
13620
|
+
* @returns The created audit record
|
|
13621
|
+
*/
|
|
13622
|
+
record(envelope, action, proof) {
|
|
13623
|
+
const record = {
|
|
13624
|
+
record_id: uuidv43(),
|
|
13625
|
+
envelope_id: envelope.message_id ?? "unknown",
|
|
13626
|
+
action,
|
|
13627
|
+
actor_id: envelope.producer_id ?? "unknown",
|
|
13628
|
+
timestamp: nowHlcStub(),
|
|
13629
|
+
proof
|
|
13630
|
+
};
|
|
13631
|
+
const envelope_id = record.envelope_id;
|
|
13632
|
+
if (!this._records.has(envelope_id)) {
|
|
13633
|
+
this._records.set(envelope_id, []);
|
|
13634
|
+
}
|
|
13635
|
+
this._records.get(envelope_id).push(record);
|
|
13636
|
+
return record;
|
|
13637
|
+
}
|
|
13638
|
+
/**
|
|
13639
|
+
* Query all audit records for a specific envelope.
|
|
13640
|
+
*
|
|
13641
|
+
* @param envelope_id - The message_id of the envelope to query
|
|
13642
|
+
* @returns List of audit records for this envelope
|
|
13643
|
+
*/
|
|
13644
|
+
query(envelope_id) {
|
|
13645
|
+
return this._records.get(envelope_id) ?? [];
|
|
13646
|
+
}
|
|
13647
|
+
/**
|
|
13648
|
+
* Get all audit records (useful for testing).
|
|
13649
|
+
*
|
|
13650
|
+
* @returns All audit records across all envelopes
|
|
13651
|
+
*/
|
|
13652
|
+
getAllRecords() {
|
|
13653
|
+
const allRecords = [];
|
|
13654
|
+
for (const records of this._records.values()) {
|
|
13655
|
+
allRecords.push(...records);
|
|
13656
|
+
}
|
|
13657
|
+
return allRecords;
|
|
13658
|
+
}
|
|
13659
|
+
/**
|
|
13660
|
+
* Clear all stored records (useful for testing).
|
|
13661
|
+
*/
|
|
13662
|
+
clear() {
|
|
13663
|
+
this._records.clear();
|
|
13664
|
+
}
|
|
13665
|
+
};
|
|
13666
|
+
|
|
13667
|
+
// src/agentConfig.ts
|
|
13668
|
+
var fs2 = __toESM(require("fs"), 1);
|
|
13669
|
+
var path4 = __toESM(require("path"), 1);
|
|
13670
|
+
function defaultEndpoints() {
|
|
13671
|
+
return {
|
|
13672
|
+
router: process.env.SW4RM_ROUTER_ADDR || "http://localhost:50051",
|
|
13673
|
+
registry: process.env.SW4RM_REGISTRY_ADDR || "http://localhost:50052",
|
|
13674
|
+
scheduler: process.env.SW4RM_SCHEDULER_ADDR || "http://localhost:50053",
|
|
13675
|
+
hitl: process.env.SW4RM_HITL_ADDR || "http://localhost:50054",
|
|
13676
|
+
worktree: process.env.SW4RM_WORKTREE_ADDR || "http://localhost:50055",
|
|
13677
|
+
tool: process.env.SW4RM_TOOL_ADDR || "http://localhost:50056",
|
|
13678
|
+
connector: process.env.SW4RM_CONNECTOR_ADDR || "http://localhost:50057",
|
|
13679
|
+
negotiation: process.env.SW4RM_NEGOTIATION_ADDR || "http://localhost:50058",
|
|
13680
|
+
reasoning: process.env.SW4RM_REASONING_ADDR || "http://localhost:50059",
|
|
13681
|
+
logging: process.env.SW4RM_LOGGING_ADDR || "http://localhost:50060"
|
|
13682
|
+
};
|
|
13683
|
+
}
|
|
13684
|
+
function defaultRetryPolicy() {
|
|
13685
|
+
return {
|
|
13686
|
+
maxAttempts: 3,
|
|
13687
|
+
initialBackoffMs: 200,
|
|
13688
|
+
maxBackoffMs: 2e3,
|
|
13689
|
+
multiplier: 2
|
|
13690
|
+
};
|
|
13691
|
+
}
|
|
13692
|
+
function defaultAgentConfig(agentId = "agent-1", name = "Agent") {
|
|
13693
|
+
return {
|
|
13694
|
+
agentId,
|
|
13695
|
+
name,
|
|
13696
|
+
description: void 0,
|
|
13697
|
+
version: "0.1.0",
|
|
13698
|
+
capabilities: [],
|
|
13699
|
+
endpoints: defaultEndpoints(),
|
|
13700
|
+
timeoutMs: 3e4,
|
|
13701
|
+
streamKeepaliveMs: 6e4,
|
|
13702
|
+
retry: defaultRetryPolicy(),
|
|
13703
|
+
metadata: {},
|
|
13704
|
+
communicationClass: 2,
|
|
13705
|
+
// STANDARD
|
|
13706
|
+
modalitiesSupported: ["application/json"],
|
|
13707
|
+
reasoningConnectors: [],
|
|
13708
|
+
publicKey: void 0
|
|
13709
|
+
};
|
|
13710
|
+
}
|
|
13711
|
+
function loadConfigFromEnv() {
|
|
13712
|
+
const config = defaultAgentConfig();
|
|
13713
|
+
if (process.env.AGENT_ID) {
|
|
13714
|
+
config.agentId = process.env.AGENT_ID;
|
|
13715
|
+
}
|
|
13716
|
+
if (process.env.AGENT_NAME) {
|
|
13717
|
+
config.name = process.env.AGENT_NAME;
|
|
13718
|
+
}
|
|
13719
|
+
if (process.env.AGENT_DESCRIPTION) {
|
|
13720
|
+
config.description = process.env.AGENT_DESCRIPTION;
|
|
13721
|
+
}
|
|
13722
|
+
if (process.env.AGENT_VERSION) {
|
|
13723
|
+
config.version = process.env.AGENT_VERSION;
|
|
13724
|
+
}
|
|
13725
|
+
if (process.env.AGENT_CAPABILITIES) {
|
|
13726
|
+
config.capabilities = process.env.AGENT_CAPABILITIES.split(",").map((s) => s.trim());
|
|
13727
|
+
}
|
|
13728
|
+
if (process.env.SW4RM_TIMEOUT_MS) {
|
|
13729
|
+
const timeout = parseInt(process.env.SW4RM_TIMEOUT_MS, 10);
|
|
13730
|
+
if (!isNaN(timeout)) {
|
|
13731
|
+
config.timeoutMs = timeout;
|
|
13732
|
+
}
|
|
13733
|
+
}
|
|
13734
|
+
if (process.env.SW4RM_STREAM_KEEPALIVE_MS) {
|
|
13735
|
+
const keepalive = parseInt(process.env.SW4RM_STREAM_KEEPALIVE_MS, 10);
|
|
13736
|
+
if (!isNaN(keepalive)) {
|
|
13737
|
+
config.streamKeepaliveMs = keepalive;
|
|
13738
|
+
}
|
|
13739
|
+
}
|
|
13740
|
+
if (process.env.SW4RM_RETRY_MAX_ATTEMPTS) {
|
|
13741
|
+
const attempts = parseInt(process.env.SW4RM_RETRY_MAX_ATTEMPTS, 10);
|
|
13742
|
+
if (!isNaN(attempts)) {
|
|
13743
|
+
config.retry.maxAttempts = attempts;
|
|
13744
|
+
}
|
|
13745
|
+
}
|
|
13746
|
+
if (process.env.SW4RM_COMMUNICATION_CLASS) {
|
|
13747
|
+
const cls = parseInt(process.env.SW4RM_COMMUNICATION_CLASS, 10);
|
|
13748
|
+
if (!isNaN(cls)) {
|
|
13749
|
+
config.communicationClass = cls;
|
|
13750
|
+
}
|
|
13751
|
+
}
|
|
13752
|
+
config.endpoints = defaultEndpoints();
|
|
13753
|
+
return config;
|
|
13754
|
+
}
|
|
13755
|
+
function defaultSW4RMConfig() {
|
|
13756
|
+
return {
|
|
13757
|
+
routerAddr: process.env.SW4RM_ROUTER_ADDR || "http://localhost:50051",
|
|
13758
|
+
registryAddr: process.env.SW4RM_REGISTRY_ADDR || "http://localhost:50052",
|
|
13759
|
+
defaultTimeoutMs: parseInt(process.env.SW4RM_DEFAULT_TIMEOUT_MS || "30000", 10),
|
|
13760
|
+
maxRetries: parseInt(process.env.SW4RM_MAX_RETRIES || "3", 10),
|
|
13761
|
+
enableMetrics: parseBool(process.env.SW4RM_ENABLE_METRICS, true),
|
|
13762
|
+
enableTracing: parseBool(process.env.SW4RM_ENABLE_TRACING, true),
|
|
13763
|
+
logLevel: process.env.SW4RM_LOG_LEVEL || "INFO",
|
|
13764
|
+
featureFlags: {}
|
|
13765
|
+
};
|
|
13766
|
+
}
|
|
13767
|
+
function parseBool(value, defaultValue) {
|
|
13768
|
+
if (value === void 0) {
|
|
13769
|
+
return defaultValue;
|
|
13770
|
+
}
|
|
13771
|
+
return ["true", "1", "yes", "on"].includes(value.toLowerCase());
|
|
13772
|
+
}
|
|
13773
|
+
function loadConfig(configPath) {
|
|
13774
|
+
let config = defaultSW4RMConfig();
|
|
13775
|
+
if (configPath) {
|
|
13776
|
+
if (!fs2.existsSync(configPath)) {
|
|
13777
|
+
throw new Error(`Configuration file not found: ${configPath}`);
|
|
13778
|
+
}
|
|
13779
|
+
const ext = path4.extname(configPath).toLowerCase();
|
|
13780
|
+
if (ext !== ".json") {
|
|
13781
|
+
throw new Error(
|
|
13782
|
+
`Unsupported configuration file format: ${ext}. Supported formats: .json`
|
|
13783
|
+
);
|
|
13784
|
+
}
|
|
13785
|
+
const fileContent = fs2.readFileSync(configPath, "utf8");
|
|
13786
|
+
const fileConfig = JSON.parse(fileContent);
|
|
13787
|
+
config = { ...config, ...fileConfig };
|
|
13788
|
+
}
|
|
13789
|
+
const envConfig = loadFromEnv();
|
|
13790
|
+
config = { ...config, ...envConfig };
|
|
13791
|
+
return config;
|
|
13792
|
+
}
|
|
13793
|
+
function loadFromEnv() {
|
|
13794
|
+
const envConfig = {};
|
|
13795
|
+
if (process.env.SW4RM_ROUTER_ADDR) {
|
|
13796
|
+
envConfig.routerAddr = process.env.SW4RM_ROUTER_ADDR;
|
|
13797
|
+
}
|
|
13798
|
+
if (process.env.SW4RM_REGISTRY_ADDR) {
|
|
13799
|
+
envConfig.registryAddr = process.env.SW4RM_REGISTRY_ADDR;
|
|
13800
|
+
}
|
|
13801
|
+
if (process.env.SW4RM_DEFAULT_TIMEOUT_MS) {
|
|
13802
|
+
const timeout = parseInt(process.env.SW4RM_DEFAULT_TIMEOUT_MS, 10);
|
|
13803
|
+
if (!isNaN(timeout)) {
|
|
13804
|
+
envConfig.defaultTimeoutMs = timeout;
|
|
13805
|
+
}
|
|
13806
|
+
}
|
|
13807
|
+
if (process.env.SW4RM_MAX_RETRIES) {
|
|
13808
|
+
const retries = parseInt(process.env.SW4RM_MAX_RETRIES, 10);
|
|
13809
|
+
if (!isNaN(retries)) {
|
|
13810
|
+
envConfig.maxRetries = retries;
|
|
13811
|
+
}
|
|
13812
|
+
}
|
|
13813
|
+
if (process.env.SW4RM_ENABLE_METRICS !== void 0) {
|
|
13814
|
+
envConfig.enableMetrics = parseBool(process.env.SW4RM_ENABLE_METRICS, true);
|
|
13815
|
+
}
|
|
13816
|
+
if (process.env.SW4RM_ENABLE_TRACING !== void 0) {
|
|
13817
|
+
envConfig.enableTracing = parseBool(process.env.SW4RM_ENABLE_TRACING, true);
|
|
13818
|
+
}
|
|
13819
|
+
if (process.env.SW4RM_LOG_LEVEL) {
|
|
13820
|
+
envConfig.logLevel = process.env.SW4RM_LOG_LEVEL.toUpperCase();
|
|
13821
|
+
}
|
|
13822
|
+
return envConfig;
|
|
13823
|
+
}
|
|
13824
|
+
var _globalConfig = null;
|
|
13825
|
+
function getConfig() {
|
|
13826
|
+
if (_globalConfig === null) {
|
|
13827
|
+
_globalConfig = loadConfig();
|
|
13828
|
+
}
|
|
13829
|
+
return _globalConfig;
|
|
13830
|
+
}
|
|
13831
|
+
function setConfig(config) {
|
|
13832
|
+
_globalConfig = config;
|
|
13833
|
+
}
|
|
13834
|
+
function resetConfig() {
|
|
13835
|
+
_globalConfig = null;
|
|
13836
|
+
}
|
|
13837
|
+
|
|
13838
|
+
// src/persistentActivityBuffer.ts
|
|
13839
|
+
var import_node_fs2 = require("node:fs");
|
|
13840
|
+
var import_node_path4 = require("node:path");
|
|
13841
|
+
var JSONFilePersistence2 = class {
|
|
13842
|
+
constructor(filePath = "sw4rm_activity.json") {
|
|
13843
|
+
this.filePath = filePath;
|
|
13844
|
+
}
|
|
13845
|
+
load() {
|
|
13846
|
+
if (!(0, import_node_fs2.existsSync)(this.filePath)) {
|
|
13847
|
+
return { records: {}, order: [] };
|
|
13848
|
+
}
|
|
13849
|
+
const raw = (0, import_node_fs2.readFileSync)(this.filePath, "utf-8");
|
|
13850
|
+
const data = JSON.parse(raw);
|
|
13851
|
+
return {
|
|
13852
|
+
records: data.records ?? {},
|
|
13853
|
+
order: data.order ?? []
|
|
13854
|
+
};
|
|
13855
|
+
}
|
|
13856
|
+
save(records, order) {
|
|
13857
|
+
const dir = (0, import_node_path4.dirname)(this.filePath);
|
|
13858
|
+
if (dir && !(0, import_node_fs2.existsSync)(dir)) {
|
|
13859
|
+
(0, import_node_fs2.mkdirSync)(dir, { recursive: true });
|
|
13860
|
+
}
|
|
13861
|
+
(0, import_node_fs2.writeFileSync)(this.filePath, JSON.stringify({ records, order, version: "1.0" }, null, 2));
|
|
13862
|
+
}
|
|
13863
|
+
clear() {
|
|
13864
|
+
if ((0, import_node_fs2.existsSync)(this.filePath)) {
|
|
13865
|
+
(0, import_node_fs2.writeFileSync)(this.filePath, JSON.stringify({ records: {}, order: [], version: "1.0" }));
|
|
13866
|
+
}
|
|
13867
|
+
}
|
|
13868
|
+
};
|
|
13869
|
+
var PersistentActivityBuffer = class {
|
|
13870
|
+
byId = /* @__PURE__ */ new Map();
|
|
13871
|
+
byIdempotencyToken = /* @__PURE__ */ new Map();
|
|
13872
|
+
// token -> message_id
|
|
13873
|
+
order = [];
|
|
13874
|
+
maxItems;
|
|
13875
|
+
persistence;
|
|
13876
|
+
dedupWindowS;
|
|
13877
|
+
dirty = false;
|
|
13878
|
+
constructor(opts) {
|
|
13879
|
+
this.maxItems = opts?.maxItems ?? 1e4;
|
|
13880
|
+
this.persistence = opts?.persistence ?? new JSONFilePersistence2();
|
|
13881
|
+
this.dedupWindowS = opts?.dedupWindowS ?? 3600;
|
|
13882
|
+
this.loadFromPersistence();
|
|
13883
|
+
}
|
|
13884
|
+
loadFromPersistence() {
|
|
13885
|
+
try {
|
|
13886
|
+
const { records, order } = this.persistence.load();
|
|
13887
|
+
this.byId = new Map(Object.entries(records));
|
|
13888
|
+
this.order = order;
|
|
13889
|
+
for (const [mid, rec] of this.byId) {
|
|
13890
|
+
const token = rec.envelope?.idempotency_token;
|
|
13891
|
+
if (token) {
|
|
13892
|
+
this.byIdempotencyToken.set(token, mid);
|
|
13893
|
+
}
|
|
13894
|
+
}
|
|
13895
|
+
} catch {
|
|
13896
|
+
this.byId = /* @__PURE__ */ new Map();
|
|
13897
|
+
this.byIdempotencyToken = /* @__PURE__ */ new Map();
|
|
13898
|
+
this.order = [];
|
|
13899
|
+
}
|
|
13900
|
+
}
|
|
13901
|
+
saveToPersistence() {
|
|
13902
|
+
if (!this.dirty)
|
|
13903
|
+
return;
|
|
13904
|
+
try {
|
|
13905
|
+
const records = {};
|
|
13906
|
+
for (const [k, v] of this.byId) {
|
|
13907
|
+
records[k] = v;
|
|
13908
|
+
}
|
|
13909
|
+
this.persistence.save(records, this.order);
|
|
13910
|
+
this.dirty = false;
|
|
13911
|
+
} catch {
|
|
13912
|
+
}
|
|
13913
|
+
}
|
|
13914
|
+
checkCapacity() {
|
|
13915
|
+
if (this.byId.size >= this.maxItems) {
|
|
13916
|
+
throw new BufferFullError(
|
|
13917
|
+
`Activity buffer is full (max ${this.maxItems} items). Reject per spec.`,
|
|
13918
|
+
1 /* BUFFER_FULL */
|
|
13919
|
+
);
|
|
13920
|
+
}
|
|
13921
|
+
}
|
|
13922
|
+
cleanupExpiredDedupEntries() {
|
|
13923
|
+
const nowMs = Date.now();
|
|
13924
|
+
const windowMs = this.dedupWindowS * 1e3;
|
|
13925
|
+
const expired = [];
|
|
13926
|
+
for (const [token, mid] of this.byIdempotencyToken) {
|
|
13927
|
+
const rec = this.byId.get(mid);
|
|
13928
|
+
if (rec && nowMs - rec.ts_ms > windowMs) {
|
|
13929
|
+
expired.push(token);
|
|
13930
|
+
}
|
|
13931
|
+
}
|
|
13932
|
+
for (const token of expired) {
|
|
13933
|
+
this.byIdempotencyToken.delete(token);
|
|
13934
|
+
}
|
|
13935
|
+
}
|
|
13936
|
+
/**
|
|
13937
|
+
* Record an incoming envelope. Throws BufferFullError if buffer is at capacity.
|
|
13938
|
+
*/
|
|
13939
|
+
recordIncoming(envelope) {
|
|
13940
|
+
this.checkCapacity();
|
|
13941
|
+
const mid = String(envelope.message_id ?? "");
|
|
13942
|
+
const rec = {
|
|
13943
|
+
message_id: mid,
|
|
13944
|
+
direction: "in",
|
|
13945
|
+
envelope,
|
|
13946
|
+
ts_ms: Date.now(),
|
|
13947
|
+
ack_stage: 0 /* ACK_STAGE_UNSPECIFIED */,
|
|
13948
|
+
error_code: 0 /* ERROR_CODE_UNSPECIFIED */,
|
|
13949
|
+
ack_note: ""
|
|
13950
|
+
};
|
|
13951
|
+
this.byId.set(mid, rec);
|
|
13952
|
+
this.order.push(mid);
|
|
13953
|
+
const token = envelope.idempotency_token;
|
|
13954
|
+
if (token) {
|
|
13955
|
+
this.byIdempotencyToken.set(token, mid);
|
|
13956
|
+
}
|
|
13957
|
+
this.cleanupExpiredDedupEntries();
|
|
13958
|
+
this.dirty = true;
|
|
13959
|
+
return rec;
|
|
13960
|
+
}
|
|
13961
|
+
/**
|
|
13962
|
+
* Record an outgoing envelope. Throws BufferFullError if buffer is at capacity.
|
|
13963
|
+
*/
|
|
13964
|
+
recordOutgoing(envelope) {
|
|
13965
|
+
this.checkCapacity();
|
|
13966
|
+
const mid = String(envelope.message_id ?? "");
|
|
13967
|
+
const rec = {
|
|
13968
|
+
message_id: mid,
|
|
13969
|
+
direction: "out",
|
|
13970
|
+
envelope,
|
|
13971
|
+
ts_ms: Date.now(),
|
|
13972
|
+
ack_stage: 0 /* ACK_STAGE_UNSPECIFIED */,
|
|
13973
|
+
error_code: 0 /* ERROR_CODE_UNSPECIFIED */,
|
|
13974
|
+
ack_note: ""
|
|
13975
|
+
};
|
|
13976
|
+
this.byId.set(mid, rec);
|
|
13977
|
+
this.order.push(mid);
|
|
13978
|
+
const token = envelope.idempotency_token;
|
|
13979
|
+
if (token) {
|
|
13980
|
+
this.byIdempotencyToken.set(token, mid);
|
|
13981
|
+
}
|
|
13982
|
+
this.cleanupExpiredDedupEntries();
|
|
13983
|
+
this.dirty = true;
|
|
13984
|
+
return rec;
|
|
13985
|
+
}
|
|
13986
|
+
/**
|
|
13987
|
+
* Process an ACK for a previously recorded message.
|
|
13988
|
+
*/
|
|
13989
|
+
ack(ackMsg) {
|
|
13990
|
+
const target = String(ackMsg.ack_for_message_id);
|
|
13991
|
+
const rec = this.byId.get(target);
|
|
13992
|
+
if (rec) {
|
|
13993
|
+
rec.ack_stage = ackMsg.ack_stage ?? 0 /* ACK_STAGE_UNSPECIFIED */;
|
|
13994
|
+
rec.error_code = ackMsg.error_code ?? 0 /* ERROR_CODE_UNSPECIFIED */;
|
|
13995
|
+
rec.ack_note = ackMsg.note ?? "";
|
|
13996
|
+
this.dirty = true;
|
|
13997
|
+
}
|
|
13998
|
+
return rec;
|
|
13999
|
+
}
|
|
14000
|
+
/** Get record by message ID. */
|
|
14001
|
+
get(messageId) {
|
|
14002
|
+
return this.byId.get(messageId);
|
|
14003
|
+
}
|
|
14004
|
+
/** Get record by idempotency token (for deduplication). */
|
|
14005
|
+
getByIdempotencyToken(token) {
|
|
14006
|
+
this.cleanupExpiredDedupEntries();
|
|
14007
|
+
const mid = this.byIdempotencyToken.get(token);
|
|
14008
|
+
if (mid)
|
|
14009
|
+
return this.byId.get(mid);
|
|
14010
|
+
return void 0;
|
|
14011
|
+
}
|
|
14012
|
+
/** Get all un-ACKed records. */
|
|
14013
|
+
unacked() {
|
|
14014
|
+
return [...this.byId.values()].filter(
|
|
14015
|
+
(r) => r.ack_stage === 0 /* ACK_STAGE_UNSPECIFIED */ || r.ack_stage === 1 /* RECEIVED */ || r.ack_stage === 2 /* READ */
|
|
14016
|
+
);
|
|
14017
|
+
}
|
|
14018
|
+
/** Get N most recent records. */
|
|
14019
|
+
recent(n = 50) {
|
|
14020
|
+
const ids = this.order.slice(-n);
|
|
14021
|
+
return ids.map((id) => this.byId.get(id)).filter(Boolean);
|
|
14022
|
+
}
|
|
14023
|
+
/** Update envelope state for a message. */
|
|
14024
|
+
updateState(messageId, newState) {
|
|
14025
|
+
const rec = this.byId.get(messageId);
|
|
14026
|
+
if (rec) {
|
|
14027
|
+
rec.envelope.state = newState;
|
|
14028
|
+
this.dirty = true;
|
|
14029
|
+
}
|
|
14030
|
+
return rec;
|
|
14031
|
+
}
|
|
14032
|
+
/** Return unacked outgoing messages for reconciliation. */
|
|
14033
|
+
reconcile() {
|
|
14034
|
+
return this.unacked().filter((r) => r.direction === "out");
|
|
14035
|
+
}
|
|
14036
|
+
/** Force save to persistence. */
|
|
14037
|
+
flush() {
|
|
14038
|
+
this.dirty = true;
|
|
14039
|
+
this.saveToPersistence();
|
|
14040
|
+
}
|
|
14041
|
+
/** Clear all records. */
|
|
14042
|
+
clear() {
|
|
14043
|
+
this.byId.clear();
|
|
14044
|
+
this.byIdempotencyToken.clear();
|
|
14045
|
+
this.order = [];
|
|
14046
|
+
this.persistence.clear();
|
|
14047
|
+
this.dirty = false;
|
|
14048
|
+
}
|
|
14049
|
+
/** Get the count of records. */
|
|
14050
|
+
get size() {
|
|
14051
|
+
return this.byId.size;
|
|
14052
|
+
}
|
|
14053
|
+
};
|
|
14054
|
+
|
|
13053
14055
|
// src/secrets/types.ts
|
|
13054
14056
|
var SecretSource = /* @__PURE__ */ ((SecretSource2) => {
|
|
13055
14057
|
SecretSource2["CLI"] = "cli";
|
|
@@ -13147,28 +14149,28 @@ var Resolver = class {
|
|
|
13147
14149
|
};
|
|
13148
14150
|
|
|
13149
14151
|
// src/secrets/backends/file.ts
|
|
13150
|
-
var
|
|
13151
|
-
var
|
|
14152
|
+
var import_node_fs3 = require("node:fs");
|
|
14153
|
+
var import_node_path5 = require("node:path");
|
|
13152
14154
|
function defaultPath() {
|
|
13153
14155
|
const isWin = process.platform === "win32";
|
|
13154
14156
|
if (isWin) {
|
|
13155
|
-
const base2 = process.env.APPDATA || (0,
|
|
13156
|
-
return (0,
|
|
14157
|
+
const base2 = process.env.APPDATA || (0, import_node_path5.join)(process.env.USERPROFILE || "", "AppData", "Roaming");
|
|
14158
|
+
return (0, import_node_path5.join)(base2, "sw4rm", "secrets.json");
|
|
13157
14159
|
}
|
|
13158
14160
|
const xdg = process.env.XDG_CONFIG_HOME;
|
|
13159
|
-
const base = xdg && xdg.length > 0 ? xdg : (0,
|
|
13160
|
-
return (0,
|
|
14161
|
+
const base = xdg && xdg.length > 0 ? xdg : (0, import_node_path5.join)(process.env.HOME || "", ".config");
|
|
14162
|
+
return (0, import_node_path5.join)(base, "sw4rm", "secrets.json");
|
|
13161
14163
|
}
|
|
13162
14164
|
var FileBackend = class {
|
|
13163
14165
|
path;
|
|
13164
|
-
constructor(
|
|
13165
|
-
this.path =
|
|
13166
|
-
(0,
|
|
14166
|
+
constructor(path5) {
|
|
14167
|
+
this.path = path5 ?? defaultPath();
|
|
14168
|
+
(0, import_node_fs3.mkdirSync)((0, import_node_path5.dirname)(this.path), { recursive: true });
|
|
13167
14169
|
try {
|
|
13168
|
-
(0,
|
|
14170
|
+
(0, import_node_fs3.chmodSync)((0, import_node_path5.dirname)(this.path), 448);
|
|
13169
14171
|
} catch {
|
|
13170
14172
|
}
|
|
13171
|
-
if (!(0,
|
|
14173
|
+
if (!(0, import_node_fs3.existsSync)(this.path)) {
|
|
13172
14174
|
this.safeWrite({});
|
|
13173
14175
|
this.enforceFilePerms();
|
|
13174
14176
|
} else {
|
|
@@ -13178,17 +14180,17 @@ var FileBackend = class {
|
|
|
13178
14180
|
enforceFilePerms() {
|
|
13179
14181
|
if (process.platform !== "win32") {
|
|
13180
14182
|
try {
|
|
13181
|
-
(0,
|
|
14183
|
+
(0, import_node_fs3.chmodSync)(this.path, 384);
|
|
13182
14184
|
} catch (e) {
|
|
13183
14185
|
throw new SecretPermissionError(String(e));
|
|
13184
14186
|
}
|
|
13185
14187
|
}
|
|
13186
14188
|
}
|
|
13187
14189
|
safeWrite(obj) {
|
|
13188
|
-
const tmp = (0,
|
|
14190
|
+
const tmp = (0, import_node_path5.join)((0, import_node_path5.dirname)(this.path), `.secrets.${Date.now()}.${Math.random().toString(16).slice(2)}`);
|
|
13189
14191
|
try {
|
|
13190
|
-
(0,
|
|
13191
|
-
(0,
|
|
14192
|
+
(0, import_node_fs3.writeFileSync)(tmp, JSON.stringify(obj, null, 2), { encoding: "utf8", mode: 384 });
|
|
14193
|
+
(0, import_node_fs3.renameSync)(tmp, this.path);
|
|
13192
14194
|
this.enforceFilePerms();
|
|
13193
14195
|
} catch (e) {
|
|
13194
14196
|
throw new SecretBackendError(String(e));
|
|
@@ -13196,7 +14198,7 @@ var FileBackend = class {
|
|
|
13196
14198
|
}
|
|
13197
14199
|
load() {
|
|
13198
14200
|
try {
|
|
13199
|
-
const s = (0,
|
|
14201
|
+
const s = (0, import_node_fs3.readFileSync)(this.path, { encoding: "utf8" });
|
|
13200
14202
|
return JSON.parse(s);
|
|
13201
14203
|
} catch (e) {
|
|
13202
14204
|
if (e.code === "ENOENT")
|
|
@@ -13293,7 +14295,7 @@ async function selectBackend(mode) {
|
|
|
13293
14295
|
}
|
|
13294
14296
|
|
|
13295
14297
|
// src/index.ts
|
|
13296
|
-
var version = "0.
|
|
14298
|
+
var version = "0.5.0";
|
|
13297
14299
|
// Annotate the CommonJS export names for ESM import in node:
|
|
13298
14300
|
0 && (module.exports = {
|
|
13299
14301
|
ACKLifecycleManager,
|
|
@@ -13306,15 +14308,22 @@ var version = "0.4.0";
|
|
|
13306
14308
|
ArtifactType,
|
|
13307
14309
|
BaseClient,
|
|
13308
14310
|
BordaCountAggregator,
|
|
14311
|
+
BufferFullError,
|
|
13309
14312
|
CT_AGENT_REPORT_V1,
|
|
13310
14313
|
CT_SCHEDULER_COMMAND_V1,
|
|
14314
|
+
CommunicationClass,
|
|
13311
14315
|
ConfidenceWeightedAggregator,
|
|
13312
14316
|
ConnectorClient,
|
|
14317
|
+
DEDUP_WINDOW_S,
|
|
14318
|
+
DEFAULT_ACK_TIMEOUT_MS,
|
|
13313
14319
|
DEFAULT_ESCALATION_POLICY,
|
|
13314
14320
|
DEFAULT_EXECUTION_POLICY,
|
|
13315
14321
|
DEFAULT_NEGOTIATION_POLICY,
|
|
14322
|
+
DebateIntensity,
|
|
13316
14323
|
DecisionOutcome,
|
|
13317
14324
|
DefaultWorktreePolicy,
|
|
14325
|
+
DuplicateDetectedError,
|
|
14326
|
+
EnvelopeState,
|
|
13318
14327
|
ErrorCode,
|
|
13319
14328
|
ErrorCodeMapper,
|
|
13320
14329
|
FileBackend,
|
|
@@ -13324,6 +14333,9 @@ var version = "0.4.0";
|
|
|
13324
14333
|
HandoffTimeoutError,
|
|
13325
14334
|
HandoffValidationError,
|
|
13326
14335
|
HitlMode,
|
|
14336
|
+
HitlReasonType,
|
|
14337
|
+
InMemoryAuditor,
|
|
14338
|
+
InMemoryNegotiationRoomStore,
|
|
13327
14339
|
InMemoryPolicyStore,
|
|
13328
14340
|
InterceptorChain,
|
|
13329
14341
|
JSONFilePersistence,
|
|
@@ -13335,15 +14347,23 @@ var version = "0.4.0";
|
|
|
13335
14347
|
MessageProcessor,
|
|
13336
14348
|
MessageType,
|
|
13337
14349
|
NegotiationClient,
|
|
14350
|
+
NegotiationError,
|
|
13338
14351
|
NegotiationRoomClient,
|
|
14352
|
+
NegotiationRoomStoreError,
|
|
13339
14353
|
NegotiationTimeoutError,
|
|
13340
14354
|
NegotiationValidationError,
|
|
14355
|
+
NoOpAuditor,
|
|
13341
14356
|
NodeStatus,
|
|
14357
|
+
PermissionError,
|
|
14358
|
+
PersistentActivityBuffer,
|
|
13342
14359
|
PersistentWorktreeState,
|
|
13343
14360
|
PolicyStoreError,
|
|
14361
|
+
PolicyViolationError,
|
|
14362
|
+
PreemptionError,
|
|
13344
14363
|
ReasoningClient,
|
|
13345
14364
|
RegistryClient,
|
|
13346
14365
|
Resolver,
|
|
14366
|
+
RouteError,
|
|
13347
14367
|
RouterClient,
|
|
13348
14368
|
RuntimePersistence,
|
|
13349
14369
|
SchedulerClient,
|
|
@@ -13361,35 +14381,57 @@ var version = "0.4.0";
|
|
|
13361
14381
|
SimpleAverageAggregator,
|
|
13362
14382
|
StateTransitionError,
|
|
13363
14383
|
Sw4rmError,
|
|
14384
|
+
TimeoutError,
|
|
13364
14385
|
ToolClient,
|
|
13365
14386
|
TriggerType,
|
|
14387
|
+
ValidationError,
|
|
13366
14388
|
VotingAnalyzer,
|
|
13367
14389
|
WorkflowClient,
|
|
13368
14390
|
WorkflowCycleError,
|
|
13369
14391
|
WorkflowStatus,
|
|
13370
14392
|
WorkflowValidationError,
|
|
13371
14393
|
WorktreeClient,
|
|
14394
|
+
WorktreeError,
|
|
14395
|
+
WorktreeStateEnum,
|
|
14396
|
+
WorktreeTransitionError,
|
|
13372
14397
|
aggregateVotes,
|
|
13373
14398
|
buildAckEnvelope,
|
|
13374
14399
|
buildEnvelope,
|
|
14400
|
+
computeEnvelopeHash,
|
|
13375
14401
|
computeIdempotencyToken,
|
|
13376
14402
|
createResilientIncomingStream,
|
|
14403
|
+
createSimpleProof,
|
|
13377
14404
|
decodeAgentReportV1,
|
|
13378
14405
|
decodeBase64,
|
|
14406
|
+
defaultAgentConfig,
|
|
14407
|
+
defaultEndpoints,
|
|
14408
|
+
defaultRetryPolicy,
|
|
14409
|
+
defaultSW4RMConfig,
|
|
13379
14410
|
durationToMs,
|
|
13380
14411
|
encodeSchedulerCommandV1,
|
|
14412
|
+
getConfig,
|
|
14413
|
+
getDefaultStore,
|
|
13381
14414
|
getValidTransitions,
|
|
14415
|
+
isTerminalEnvelopeState,
|
|
13382
14416
|
isValidTransition,
|
|
14417
|
+
isValidWorktreeTransition,
|
|
14418
|
+
loadConfig,
|
|
14419
|
+
loadConfigFromEnv,
|
|
13383
14420
|
loggingInterceptor,
|
|
13384
14421
|
mapGrpcStatusToErrorCode,
|
|
13385
14422
|
msToDuration,
|
|
13386
14423
|
normalizeReportPaths,
|
|
13387
14424
|
nowTimestamp,
|
|
13388
14425
|
parseNegotiationEvent,
|
|
14426
|
+
resetConfig,
|
|
14427
|
+
resetDefaultStore,
|
|
13389
14428
|
selectBackend,
|
|
13390
14429
|
sendMessageWithAck,
|
|
14430
|
+
setConfig,
|
|
13391
14431
|
timingInterceptor,
|
|
14432
|
+
updateEnvelopeState,
|
|
13392
14433
|
uuidv4,
|
|
14434
|
+
verifyAuditProof,
|
|
13393
14435
|
version
|
|
13394
14436
|
});
|
|
13395
14437
|
/*! Bundled license information:
|