@ai-devkit/daemon-client 0.0.0-stage → 0.1.1
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/dist/__tests__/client.test.d.ts +2 -0
- package/dist/__tests__/client.test.d.ts.map +1 -0
- package/dist/__tests__/client.test.js +117 -0
- package/dist/__tests__/integration.test.d.ts +2 -0
- package/dist/__tests__/integration.test.d.ts.map +1 -0
- package/dist/__tests__/integration.test.js +534 -0
- package/dist/autostart.d.ts +11 -0
- package/dist/autostart.d.ts.map +1 -0
- package/dist/autostart.js +321 -0
- package/dist/binary.d.ts +10 -0
- package/dist/binary.d.ts.map +1 -0
- package/dist/binary.js +67 -0
- package/dist/client.d.ts +44 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +477 -0
- package/dist/gen/EnrichedAgent.d.ts +24 -0
- package/dist/gen/EnrichedAgent.d.ts.map +1 -0
- package/dist/gen/EnrichedAgent.js +5 -0
- package/dist/gen/Event.d.ts +11 -0
- package/dist/gen/Event.d.ts.map +1 -0
- package/dist/gen/Event.js +5 -0
- package/dist/gen/Request.d.ts +9 -0
- package/dist/gen/Request.d.ts.map +1 -0
- package/dist/gen/Request.js +4 -0
- package/dist/gen/Response.d.ts +6 -0
- package/dist/gen/Response.d.ts.map +1 -0
- package/dist/gen/Response.js +2 -0
- package/dist/gen/index.d.ts +5 -0
- package/dist/gen/index.d.ts.map +1 -0
- package/dist/gen/index.js +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/package.json +44 -4
- package/README.md +0 -3
package/dist/client.js
ADDED
|
@@ -0,0 +1,477 @@
|
|
|
1
|
+
function _array_like_to_array(arr, len) {
|
|
2
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
3
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
4
|
+
return arr2;
|
|
5
|
+
}
|
|
6
|
+
function _array_without_holes(arr) {
|
|
7
|
+
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
8
|
+
}
|
|
9
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
10
|
+
try {
|
|
11
|
+
var info = gen[key](arg);
|
|
12
|
+
var value = info.value;
|
|
13
|
+
} catch (error) {
|
|
14
|
+
reject(error);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
if (info.done) {
|
|
18
|
+
resolve(value);
|
|
19
|
+
} else {
|
|
20
|
+
Promise.resolve(value).then(_next, _throw);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function _async_to_generator(fn) {
|
|
24
|
+
return function() {
|
|
25
|
+
var self = this, args = arguments;
|
|
26
|
+
return new Promise(function(resolve, reject) {
|
|
27
|
+
var gen = fn.apply(self, args);
|
|
28
|
+
function _next(value) {
|
|
29
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
30
|
+
}
|
|
31
|
+
function _throw(err) {
|
|
32
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
33
|
+
}
|
|
34
|
+
_next(undefined);
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function _class_call_check(instance, Constructor) {
|
|
39
|
+
if (!(instance instanceof Constructor)) {
|
|
40
|
+
throw new TypeError("Cannot call a class as a function");
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function _defineProperties(target, props) {
|
|
44
|
+
for(var i = 0; i < props.length; i++){
|
|
45
|
+
var descriptor = props[i];
|
|
46
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
47
|
+
descriptor.configurable = true;
|
|
48
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
49
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
53
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
54
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
55
|
+
return Constructor;
|
|
56
|
+
}
|
|
57
|
+
function _define_property(obj, key, value) {
|
|
58
|
+
if (key in obj) {
|
|
59
|
+
Object.defineProperty(obj, key, {
|
|
60
|
+
value: value,
|
|
61
|
+
enumerable: true,
|
|
62
|
+
configurable: true,
|
|
63
|
+
writable: true
|
|
64
|
+
});
|
|
65
|
+
} else {
|
|
66
|
+
obj[key] = value;
|
|
67
|
+
}
|
|
68
|
+
return obj;
|
|
69
|
+
}
|
|
70
|
+
function _iterable_to_array(iter) {
|
|
71
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
72
|
+
}
|
|
73
|
+
function _non_iterable_spread() {
|
|
74
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
75
|
+
}
|
|
76
|
+
function _to_consumable_array(arr) {
|
|
77
|
+
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
78
|
+
}
|
|
79
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
80
|
+
if (!o) return;
|
|
81
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
82
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
83
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
84
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
85
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
86
|
+
}
|
|
87
|
+
function _ts_generator(thisArg, body) {
|
|
88
|
+
var f, y, t, _ = {
|
|
89
|
+
label: 0,
|
|
90
|
+
sent: function() {
|
|
91
|
+
if (t[0] & 1) throw t[1];
|
|
92
|
+
return t[1];
|
|
93
|
+
},
|
|
94
|
+
trys: [],
|
|
95
|
+
ops: []
|
|
96
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
97
|
+
return d(g, "next", {
|
|
98
|
+
value: verb(0)
|
|
99
|
+
}), d(g, "throw", {
|
|
100
|
+
value: verb(1)
|
|
101
|
+
}), d(g, "return", {
|
|
102
|
+
value: verb(2)
|
|
103
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
104
|
+
value: function() {
|
|
105
|
+
return this;
|
|
106
|
+
}
|
|
107
|
+
}), g;
|
|
108
|
+
function verb(n) {
|
|
109
|
+
return function(v) {
|
|
110
|
+
return step([
|
|
111
|
+
n,
|
|
112
|
+
v
|
|
113
|
+
]);
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
function step(op) {
|
|
117
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
118
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
119
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
120
|
+
if (y = 0, t) op = [
|
|
121
|
+
op[0] & 2,
|
|
122
|
+
t.value
|
|
123
|
+
];
|
|
124
|
+
switch(op[0]){
|
|
125
|
+
case 0:
|
|
126
|
+
case 1:
|
|
127
|
+
t = op;
|
|
128
|
+
break;
|
|
129
|
+
case 4:
|
|
130
|
+
_.label++;
|
|
131
|
+
return {
|
|
132
|
+
value: op[1],
|
|
133
|
+
done: false
|
|
134
|
+
};
|
|
135
|
+
case 5:
|
|
136
|
+
_.label++;
|
|
137
|
+
y = op[1];
|
|
138
|
+
op = [
|
|
139
|
+
0
|
|
140
|
+
];
|
|
141
|
+
continue;
|
|
142
|
+
case 7:
|
|
143
|
+
op = _.ops.pop();
|
|
144
|
+
_.trys.pop();
|
|
145
|
+
continue;
|
|
146
|
+
default:
|
|
147
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
148
|
+
_ = 0;
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
152
|
+
_.label = op[1];
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
156
|
+
_.label = t[1];
|
|
157
|
+
t = op;
|
|
158
|
+
break;
|
|
159
|
+
}
|
|
160
|
+
if (t && _.label < t[2]) {
|
|
161
|
+
_.label = t[2];
|
|
162
|
+
_.ops.push(op);
|
|
163
|
+
break;
|
|
164
|
+
}
|
|
165
|
+
if (t[2]) _.ops.pop();
|
|
166
|
+
_.trys.pop();
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
op = body.call(thisArg, _);
|
|
170
|
+
} catch (e) {
|
|
171
|
+
op = [
|
|
172
|
+
6,
|
|
173
|
+
e
|
|
174
|
+
];
|
|
175
|
+
y = 0;
|
|
176
|
+
} finally{
|
|
177
|
+
f = t = 0;
|
|
178
|
+
}
|
|
179
|
+
if (op[0] & 5) throw op[1];
|
|
180
|
+
return {
|
|
181
|
+
value: op[0] ? op[1] : void 0,
|
|
182
|
+
done: true
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
import * as net from "node:net";
|
|
187
|
+
import * as os from "node:os";
|
|
188
|
+
import * as path from "node:path";
|
|
189
|
+
export function daemonSocketPath() {
|
|
190
|
+
return path.join(os.homedir(), ".ai-devkit", "daemon.sock");
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Line-delimited JSON-RPC client for devkitd. One request per line;
|
|
194
|
+
* events arrive as `{"event": {...}}` frames after `subscribe`.
|
|
195
|
+
*/ export var DaemonClient = /*#__PURE__*/ function() {
|
|
196
|
+
"use strict";
|
|
197
|
+
function DaemonClient(socketPath) {
|
|
198
|
+
var requestTimeoutMs = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 30000;
|
|
199
|
+
_class_call_check(this, DaemonClient);
|
|
200
|
+
_define_property(this, "socketPath", void 0);
|
|
201
|
+
_define_property(this, "requestTimeoutMs", void 0);
|
|
202
|
+
_define_property(this, "socket", void 0);
|
|
203
|
+
_define_property(this, "nextId", void 0);
|
|
204
|
+
_define_property(this, "pending", void 0);
|
|
205
|
+
_define_property(this, "buffer", void 0);
|
|
206
|
+
_define_property(this, "onEvent", void 0);
|
|
207
|
+
/**
|
|
208
|
+
* Fires once when the socket dies after a successful connect (daemon
|
|
209
|
+
* restart, crash). Consoles use it to resubscribe instead of silently
|
|
210
|
+
* falling back to polling forever.
|
|
211
|
+
*/ _define_property(this, "onDisconnect", void 0);
|
|
212
|
+
this.socketPath = socketPath;
|
|
213
|
+
this.requestTimeoutMs = requestTimeoutMs;
|
|
214
|
+
this.socket = null;
|
|
215
|
+
this.nextId = 1;
|
|
216
|
+
this.pending = new Map();
|
|
217
|
+
this.buffer = "";
|
|
218
|
+
this.onEvent = null;
|
|
219
|
+
this.onDisconnect = null;
|
|
220
|
+
}
|
|
221
|
+
_create_class(DaemonClient, [
|
|
222
|
+
{
|
|
223
|
+
key: "request",
|
|
224
|
+
value: function request(method) {
|
|
225
|
+
var _this = this;
|
|
226
|
+
var params = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
227
|
+
if (!this.socket) return Promise.reject(new Error("not connected"));
|
|
228
|
+
var id = this.nextId++;
|
|
229
|
+
return new Promise(function(resolve, reject) {
|
|
230
|
+
// A dead-but-unreported socket or a wedged daemon must not leave
|
|
231
|
+
// callers awaiting forever.
|
|
232
|
+
var timer = setTimeout(function() {
|
|
233
|
+
if (_this.pending.delete(id)) {
|
|
234
|
+
reject(new Error('daemon request "'.concat(method, '" timed out')));
|
|
235
|
+
}
|
|
236
|
+
}, _this.requestTimeoutMs);
|
|
237
|
+
_this.pending.set(id, {
|
|
238
|
+
resolve: resolve,
|
|
239
|
+
reject: reject,
|
|
240
|
+
timer: timer
|
|
241
|
+
});
|
|
242
|
+
_this.socket.write(JSON.stringify({
|
|
243
|
+
id: id,
|
|
244
|
+
method: method,
|
|
245
|
+
params: params
|
|
246
|
+
}) + "\n");
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
key: "subscribe",
|
|
252
|
+
value: function subscribe(_0) {
|
|
253
|
+
return _async_to_generator(function(handler) {
|
|
254
|
+
var opts, _opts_afterSeq;
|
|
255
|
+
var _arguments = arguments;
|
|
256
|
+
return _ts_generator(this, function(_state) {
|
|
257
|
+
switch(_state.label){
|
|
258
|
+
case 0:
|
|
259
|
+
opts = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {};
|
|
260
|
+
this.onEvent = handler;
|
|
261
|
+
return [
|
|
262
|
+
4,
|
|
263
|
+
this.request("subscribe", {
|
|
264
|
+
afterSeq: (_opts_afterSeq = opts.afterSeq) !== null && _opts_afterSeq !== void 0 ? _opts_afterSeq : 0,
|
|
265
|
+
liveOnly: opts.liveOnly
|
|
266
|
+
})
|
|
267
|
+
];
|
|
268
|
+
case 1:
|
|
269
|
+
_state.sent();
|
|
270
|
+
return [
|
|
271
|
+
2
|
|
272
|
+
];
|
|
273
|
+
}
|
|
274
|
+
});
|
|
275
|
+
}).apply(this, arguments);
|
|
276
|
+
}
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
key: "listAgents",
|
|
280
|
+
value: /**
|
|
281
|
+
* The daemon's fully attributed agent list — authoritative for every
|
|
282
|
+
* harness type the daemon serves. Throws on RPC error: callers fall back
|
|
283
|
+
* to local adapters for the whole call, not per-agent.
|
|
284
|
+
*/ function listAgents() {
|
|
285
|
+
return _async_to_generator(function() {
|
|
286
|
+
return _ts_generator(this, function(_state) {
|
|
287
|
+
switch(_state.label){
|
|
288
|
+
case 0:
|
|
289
|
+
return [
|
|
290
|
+
4,
|
|
291
|
+
this.request("agent.list")
|
|
292
|
+
];
|
|
293
|
+
case 1:
|
|
294
|
+
return [
|
|
295
|
+
2,
|
|
296
|
+
_state.sent()
|
|
297
|
+
];
|
|
298
|
+
}
|
|
299
|
+
});
|
|
300
|
+
}).call(this);
|
|
301
|
+
}
|
|
302
|
+
},
|
|
303
|
+
{
|
|
304
|
+
key: "onData",
|
|
305
|
+
value: function onData(chunk) {
|
|
306
|
+
this.buffer += chunk.toString("utf8");
|
|
307
|
+
var idx;
|
|
308
|
+
while((idx = this.buffer.indexOf("\n")) >= 0){
|
|
309
|
+
var line = this.buffer.slice(0, idx);
|
|
310
|
+
this.buffer = this.buffer.slice(idx + 1);
|
|
311
|
+
if (!line.trim()) continue;
|
|
312
|
+
var msg = void 0;
|
|
313
|
+
try {
|
|
314
|
+
msg = JSON.parse(line);
|
|
315
|
+
} catch (unused) {
|
|
316
|
+
continue;
|
|
317
|
+
}
|
|
318
|
+
if (msg.event) {
|
|
319
|
+
var _this_onEvent, _this;
|
|
320
|
+
(_this_onEvent = (_this = this).onEvent) === null || _this_onEvent === void 0 ? void 0 : _this_onEvent.call(_this, msg.event);
|
|
321
|
+
continue;
|
|
322
|
+
}
|
|
323
|
+
var id = msg.id;
|
|
324
|
+
var p = this.pending.get(id);
|
|
325
|
+
if (!p) continue;
|
|
326
|
+
this.pending.delete(id);
|
|
327
|
+
clearTimeout(p.timer);
|
|
328
|
+
if (msg.error) p.reject(new Error(String(msg.error)));
|
|
329
|
+
else p.resolve(msg.result);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
},
|
|
333
|
+
{
|
|
334
|
+
key: "onSocketDead",
|
|
335
|
+
value: /** Reject every in-flight request and mark the socket dead. Idempotent. */ function onSocketDead(err) {
|
|
336
|
+
var _this_onDisconnect, _this;
|
|
337
|
+
if (!this.socket) return;
|
|
338
|
+
this.socket = null;
|
|
339
|
+
var pending = _to_consumable_array(this.pending.values());
|
|
340
|
+
this.pending.clear();
|
|
341
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
342
|
+
try {
|
|
343
|
+
for(var _iterator = pending[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
344
|
+
var p = _step.value;
|
|
345
|
+
clearTimeout(p.timer);
|
|
346
|
+
p.reject(err);
|
|
347
|
+
}
|
|
348
|
+
} catch (err) {
|
|
349
|
+
_didIteratorError = true;
|
|
350
|
+
_iteratorError = err;
|
|
351
|
+
} finally{
|
|
352
|
+
try {
|
|
353
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
354
|
+
_iterator.return();
|
|
355
|
+
}
|
|
356
|
+
} finally{
|
|
357
|
+
if (_didIteratorError) {
|
|
358
|
+
throw _iteratorError;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
(_this_onDisconnect = (_this = this).onDisconnect) === null || _this_onDisconnect === void 0 ? void 0 : _this_onDisconnect.call(_this);
|
|
363
|
+
}
|
|
364
|
+
},
|
|
365
|
+
{
|
|
366
|
+
key: "close",
|
|
367
|
+
value: function close() {
|
|
368
|
+
if (!this.socket) return;
|
|
369
|
+
var socket = this.socket;
|
|
370
|
+
this.socket = null;
|
|
371
|
+
socket.destroy();
|
|
372
|
+
var pending = _to_consumable_array(this.pending.values());
|
|
373
|
+
this.pending.clear();
|
|
374
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
375
|
+
try {
|
|
376
|
+
for(var _iterator = pending[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
377
|
+
var p = _step.value;
|
|
378
|
+
clearTimeout(p.timer);
|
|
379
|
+
p.reject(new Error("client closed"));
|
|
380
|
+
}
|
|
381
|
+
} catch (err) {
|
|
382
|
+
_didIteratorError = true;
|
|
383
|
+
_iteratorError = err;
|
|
384
|
+
} finally{
|
|
385
|
+
try {
|
|
386
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
387
|
+
_iterator.return();
|
|
388
|
+
}
|
|
389
|
+
} finally{
|
|
390
|
+
if (_didIteratorError) {
|
|
391
|
+
throw _iteratorError;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
], [
|
|
398
|
+
{
|
|
399
|
+
key: "connect",
|
|
400
|
+
value: function connect() {
|
|
401
|
+
var socketPath = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : daemonSocketPath(), timeoutMs = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 1500, requestTimeoutMs = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 30000;
|
|
402
|
+
return new Promise(function(resolve, reject) {
|
|
403
|
+
var client = new DaemonClient(socketPath, requestTimeoutMs);
|
|
404
|
+
var socket = net.createConnection(socketPath);
|
|
405
|
+
var timer = setTimeout(function() {
|
|
406
|
+
socket.destroy();
|
|
407
|
+
reject(new Error("daemon connect timeout"));
|
|
408
|
+
}, timeoutMs);
|
|
409
|
+
socket.once("connect", function() {
|
|
410
|
+
clearTimeout(timer);
|
|
411
|
+
client.socket = socket;
|
|
412
|
+
socket.on("data", function(d) {
|
|
413
|
+
return client.onData(d);
|
|
414
|
+
});
|
|
415
|
+
// Persistent listeners — a once("error") handler would be consumed
|
|
416
|
+
// by the first error, leaving later ones unhandled (which crashes
|
|
417
|
+
// the process). Both paths drain pending and notify onDisconnect.
|
|
418
|
+
socket.on("error", function(e) {
|
|
419
|
+
return client.onSocketDead(e);
|
|
420
|
+
});
|
|
421
|
+
socket.on("close", function() {
|
|
422
|
+
return client.onSocketDead(new Error("daemon socket closed"));
|
|
423
|
+
});
|
|
424
|
+
resolve(client);
|
|
425
|
+
});
|
|
426
|
+
socket.once("error", function(e) {
|
|
427
|
+
clearTimeout(timer);
|
|
428
|
+
reject(e);
|
|
429
|
+
});
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
},
|
|
433
|
+
{
|
|
434
|
+
key: "tryConnect",
|
|
435
|
+
value: /** Null when the socket is absent/unreachable — callers fall back. */ function tryConnect() {
|
|
436
|
+
return _async_to_generator(function() {
|
|
437
|
+
var socketPath, unused;
|
|
438
|
+
var _arguments = arguments;
|
|
439
|
+
return _ts_generator(this, function(_state) {
|
|
440
|
+
switch(_state.label){
|
|
441
|
+
case 0:
|
|
442
|
+
socketPath = _arguments.length > 0 && _arguments[0] !== void 0 ? _arguments[0] : daemonSocketPath();
|
|
443
|
+
_state.label = 1;
|
|
444
|
+
case 1:
|
|
445
|
+
_state.trys.push([
|
|
446
|
+
1,
|
|
447
|
+
3,
|
|
448
|
+
,
|
|
449
|
+
4
|
|
450
|
+
]);
|
|
451
|
+
return [
|
|
452
|
+
4,
|
|
453
|
+
DaemonClient.connect(socketPath)
|
|
454
|
+
];
|
|
455
|
+
case 2:
|
|
456
|
+
return [
|
|
457
|
+
2,
|
|
458
|
+
_state.sent()
|
|
459
|
+
];
|
|
460
|
+
case 3:
|
|
461
|
+
unused = _state.sent();
|
|
462
|
+
return [
|
|
463
|
+
2,
|
|
464
|
+
null
|
|
465
|
+
];
|
|
466
|
+
case 4:
|
|
467
|
+
return [
|
|
468
|
+
2
|
|
469
|
+
];
|
|
470
|
+
}
|
|
471
|
+
});
|
|
472
|
+
}).apply(this, arguments);
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
]);
|
|
476
|
+
return DaemonClient;
|
|
477
|
+
}();
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fully attributed agent, mirroring agent-manager's `AgentInfo` exactly —
|
|
3
|
+
* the wire shape TS clients already consume from `listAgents`.
|
|
4
|
+
*/
|
|
5
|
+
export type EnrichedAgent = {
|
|
6
|
+
name: string;
|
|
7
|
+
type: string;
|
|
8
|
+
/**
|
|
9
|
+
* "running" | "waiting" | "idle" | "unknown" — string so future harness
|
|
10
|
+
* states don't churn the schema.
|
|
11
|
+
*/
|
|
12
|
+
status: string;
|
|
13
|
+
summary: string;
|
|
14
|
+
pid: number;
|
|
15
|
+
projectPath: string;
|
|
16
|
+
sessionId: string;
|
|
17
|
+
/**
|
|
18
|
+
* ISO-8601 — TS `Date` crosses the wire as a string.
|
|
19
|
+
*/
|
|
20
|
+
lastActive: string;
|
|
21
|
+
pinned?: boolean;
|
|
22
|
+
sessionFilePath?: string;
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=EnrichedAgent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EnrichedAgent.d.ts","sourceRoot":"","sources":["../../src/gen/EnrichedAgent.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IACzD;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IACrF;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAAC,eAAe,CAAC,EAAE,MAAM,CAAC;CAAE,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
|
2
|
+
/**
|
|
3
|
+
* Fully attributed agent, mirroring agent-manager's `AgentInfo` exactly —
|
|
4
|
+
* the wire shape TS clients already consume from `listAgents`.
|
|
5
|
+
*/ export { };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Event pushed to subscribers. `seq` is the persisted log sequence number —
|
|
3
|
+
* subscribers ack by seq to get at-least-once delivery.
|
|
4
|
+
*/
|
|
5
|
+
export type Event = {
|
|
6
|
+
seq: number;
|
|
7
|
+
ts: number;
|
|
8
|
+
kind: string;
|
|
9
|
+
payload: unknown;
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=Event.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Event.d.ts","sourceRoot":"","sources":["../../src/gen/Event.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,MAAM,KAAK,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAC;CAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Request.d.ts","sourceRoot":"","sources":["../../src/gen/Request.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,MAAM,OAAO,GAAG;IAAE,EAAE,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAC;CAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Response.d.ts","sourceRoot":"","sources":["../../src/gen/Response.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,QAAQ,GAAG;IAAE,EAAE,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/gen/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,YAAY,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACxC,YAAY,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,YAAY,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { DaemonClient, daemonSocketPath } from "./client.js";
|
|
2
|
+
export type { DaemonEvent } from "./client.js";
|
|
3
|
+
export type { EnrichedAgent, Event } from "./gen/index.js";
|
|
4
|
+
export { resolveDaemonBinary } from "./binary.js";
|
|
5
|
+
export { ensureDaemon } from "./autostart.js";
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC7D,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,YAAY,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/index.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,46 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-devkit/daemon-client",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Thin client for the devkitd coordination daemon (unix socket, JSON-RPC, subscribe)",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/codeaholicguy/ai-devkit.git",
|
|
9
|
+
"directory": "packages/daemon-client"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"README.md"
|
|
14
|
+
],
|
|
15
|
+
"type": "module",
|
|
16
|
+
"main": "dist/index.js",
|
|
17
|
+
"types": "dist/index.d.ts",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"import": "./dist/index.js"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "swc src -d dist --strip-leading-paths && tsc --emitDeclarationOnly",
|
|
26
|
+
"dev": "swc src -d dist --strip-leading-paths --watch",
|
|
27
|
+
"typecheck": "tsc --noEmit",
|
|
28
|
+
"test": "vitest run",
|
|
29
|
+
"lint": "oxlint src",
|
|
30
|
+
"fmt": "oxfmt",
|
|
31
|
+
"fmt:check": "oxfmt --check",
|
|
32
|
+
"clean": "rm -rf dist"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@swc/cli": "^0.8.1",
|
|
36
|
+
"@swc/core": "^1.10.0",
|
|
37
|
+
"@types/node": "^20.11.5",
|
|
38
|
+
"vitest": "^4.1.8"
|
|
39
|
+
},
|
|
40
|
+
"optionalDependencies": {
|
|
41
|
+
"@ai-devkit/devkitd-darwin-arm64": "0.1.1",
|
|
42
|
+
"@ai-devkit/devkitd-darwin-x64": "0.1.1",
|
|
43
|
+
"@ai-devkit/devkitd-linux-arm64": "0.1.1",
|
|
44
|
+
"@ai-devkit/devkitd-linux-x64": "0.1.1"
|
|
45
|
+
}
|
|
46
|
+
}
|
package/README.md
DELETED