@ai-devkit/daemon-client 0.2.1 → 0.3.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/dist/__tests__/autostart-stale.test.d.ts +2 -0
- package/dist/__tests__/autostart-stale.test.d.ts.map +1 -0
- package/dist/__tests__/autostart-stale.test.js +809 -0
- package/dist/__tests__/integration.test.js +193 -169
- package/dist/autostart.d.ts +6 -0
- package/dist/autostart.d.ts.map +1 -1
- package/dist/autostart.js +373 -48
- package/dist/binary.d.ts +18 -1
- package/dist/binary.d.ts.map +1 -1
- package/dist/binary.js +42 -6
- package/dist/client.d.ts +24 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +85 -0
- package/dist/gen/AgentLookupResult.d.ts +29 -0
- package/dist/gen/AgentLookupResult.d.ts.map +1 -0
- package/dist/gen/AgentLookupResult.js +12 -0
- package/dist/gen/AgentNameParams.d.ts +8 -0
- package/dist/gen/AgentNameParams.d.ts.map +1 -0
- package/dist/gen/AgentNameParams.js +5 -0
- package/dist/gen/AgentRenameParams.d.ts +8 -0
- package/dist/gen/AgentRenameParams.d.ts.map +1 -0
- package/dist/gen/AgentRenameParams.js +4 -0
- package/dist/gen/AgentRenameResult.d.ts +18 -0
- package/dist/gen/AgentRenameResult.d.ts.map +1 -0
- package/dist/gen/AgentRenameResult.js +6 -0
- package/dist/gen/AgentUnregisterResult.d.ts +8 -0
- package/dist/gen/AgentUnregisterResult.d.ts.map +1 -0
- package/dist/gen/AgentUnregisterResult.js +4 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/package.json +5 -5
- package/dist/__tests__/daemon-sweep.test.d.ts +0 -2
- package/dist/__tests__/daemon-sweep.test.d.ts.map +0 -1
- package/dist/__tests__/daemon-sweep.test.js +0 -356
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names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CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAOvE,OAAO,CAAC,MAAM;IA8Bd,2EAA2E;IAC3E,OAAO,CAAC,YAAY;IAYpB,KAAK;CAYN"}
|
package/dist/client.js
CHANGED
|
@@ -444,6 +444,91 @@ export function daemonSocketPath() {
|
|
|
444
444
|
}).call(this);
|
|
445
445
|
}
|
|
446
446
|
},
|
|
447
|
+
{
|
|
448
|
+
key: "lookupAgent",
|
|
449
|
+
value: /**
|
|
450
|
+
* Resolve an exact registered name to its location data (pid, runtime,
|
|
451
|
+
* runtimeRef, cwd, liveness). Dead/tombstoned registrations resolve with
|
|
452
|
+
* `alive: false`; unknown names reject with `DaemonRpcError` code
|
|
453
|
+
* `not_found`. Generic on purpose — kill, send, open, channel and console
|
|
454
|
+
* all drive their runtime ops from this payload.
|
|
455
|
+
*/ function lookupAgent(name) {
|
|
456
|
+
return _async_to_generator(function() {
|
|
457
|
+
return _ts_generator(this, function(_state) {
|
|
458
|
+
switch(_state.label){
|
|
459
|
+
case 0:
|
|
460
|
+
return [
|
|
461
|
+
4,
|
|
462
|
+
this.request("agent.lookup", {
|
|
463
|
+
name: name
|
|
464
|
+
})
|
|
465
|
+
];
|
|
466
|
+
case 1:
|
|
467
|
+
return [
|
|
468
|
+
2,
|
|
469
|
+
_state.sent()
|
|
470
|
+
];
|
|
471
|
+
}
|
|
472
|
+
});
|
|
473
|
+
}).call(this);
|
|
474
|
+
}
|
|
475
|
+
},
|
|
476
|
+
{
|
|
477
|
+
key: "unregisterAgent",
|
|
478
|
+
value: /**
|
|
479
|
+
* Remove a name's registration outright (no tombstone) so the name is free
|
|
480
|
+
* for the next start. Does not touch the runtime — teardown is the
|
|
481
|
+
* caller's job, using `lookupAgent` data. Rejects `not_found` if unknown.
|
|
482
|
+
*/ function unregisterAgent(name) {
|
|
483
|
+
return _async_to_generator(function() {
|
|
484
|
+
return _ts_generator(this, function(_state) {
|
|
485
|
+
switch(_state.label){
|
|
486
|
+
case 0:
|
|
487
|
+
return [
|
|
488
|
+
4,
|
|
489
|
+
this.request("agent.unregister", {
|
|
490
|
+
name: name
|
|
491
|
+
})
|
|
492
|
+
];
|
|
493
|
+
case 1:
|
|
494
|
+
return [
|
|
495
|
+
2,
|
|
496
|
+
_state.sent()
|
|
497
|
+
];
|
|
498
|
+
}
|
|
499
|
+
});
|
|
500
|
+
}).call(this);
|
|
501
|
+
}
|
|
502
|
+
},
|
|
503
|
+
{
|
|
504
|
+
key: "renameAgent",
|
|
505
|
+
value: /**
|
|
506
|
+
* Rename a registered agent and its runtime handle (tmux session / live
|
|
507
|
+
* herdr agent) atomically, daemon-side. Rejects coded `not_found`,
|
|
508
|
+
* `name_in_use`, `runtime_rename_failed` (registry left unchanged),
|
|
509
|
+
* `runtime_unavailable`, `invalid_params`.
|
|
510
|
+
*/ function renameAgent(from, to) {
|
|
511
|
+
return _async_to_generator(function() {
|
|
512
|
+
return _ts_generator(this, function(_state) {
|
|
513
|
+
switch(_state.label){
|
|
514
|
+
case 0:
|
|
515
|
+
return [
|
|
516
|
+
4,
|
|
517
|
+
this.request("agent.rename", {
|
|
518
|
+
from: from,
|
|
519
|
+
to: to
|
|
520
|
+
})
|
|
521
|
+
];
|
|
522
|
+
case 1:
|
|
523
|
+
return [
|
|
524
|
+
2,
|
|
525
|
+
_state.sent()
|
|
526
|
+
];
|
|
527
|
+
}
|
|
528
|
+
});
|
|
529
|
+
}).call(this);
|
|
530
|
+
}
|
|
531
|
+
},
|
|
447
532
|
{
|
|
448
533
|
key: "onData",
|
|
449
534
|
value: function onData(chunk) {
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `agent.lookup` result — a registered agent's location data, enough for a
|
|
3
|
+
* client to drive its runtime directly (tmux `kill-session`/`send-keys` via
|
|
4
|
+
* `runtimeRef.session`, herdr pane ops via `runtimeRef.paneId`). Generic on
|
|
5
|
+
* purpose: kill, send, open, channel and console all resolve through it.
|
|
6
|
+
*
|
|
7
|
+
* Tombstoned registrations (process gone, row retained for cleanup) resolve
|
|
8
|
+
* too: `alive` is false and `goneAt` carries the sweep timestamp (ms).
|
|
9
|
+
* `alive` is a `kill(pid, 0)` probe at lookup time — callers must not
|
|
10
|
+
* signal `pid` when it is false (the number may since have been recycled).
|
|
11
|
+
*/
|
|
12
|
+
export type AgentLookupResult = {
|
|
13
|
+
name: string;
|
|
14
|
+
type: string;
|
|
15
|
+
pid: number;
|
|
16
|
+
/**
|
|
17
|
+
* Runtime provider: "tmux" | "herdr".
|
|
18
|
+
*/
|
|
19
|
+
runtime: string;
|
|
20
|
+
/**
|
|
21
|
+
* Provider-specific handle; `null` when the registration has none.
|
|
22
|
+
*/
|
|
23
|
+
runtimeRef: unknown;
|
|
24
|
+
cwd: string;
|
|
25
|
+
pinned: boolean;
|
|
26
|
+
alive: boolean;
|
|
27
|
+
goneAt?: number;
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=AgentLookupResult.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgentLookupResult.d.ts","sourceRoot":"","sources":["../../src/gen/AgentLookupResult.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAC1E;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,UAAU,EAAE,OAAO,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAAE,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
|
2
|
+
/**
|
|
3
|
+
* `agent.lookup` result — a registered agent's location data, enough for a
|
|
4
|
+
* client to drive its runtime directly (tmux `kill-session`/`send-keys` via
|
|
5
|
+
* `runtimeRef.session`, herdr pane ops via `runtimeRef.paneId`). Generic on
|
|
6
|
+
* purpose: kill, send, open, channel and console all resolve through it.
|
|
7
|
+
*
|
|
8
|
+
* Tombstoned registrations (process gone, row retained for cleanup) resolve
|
|
9
|
+
* too: `alive` is false and `goneAt` carries the sweep timestamp (ms).
|
|
10
|
+
* `alive` is a `kill(pid, 0)` probe at lookup time — callers must not
|
|
11
|
+
* signal `pid` when it is false (the number may since have been recycled).
|
|
12
|
+
*/ export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgentNameParams.d.ts","sourceRoot":"","sources":["../../src/gen/AgentNameParams.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG;IAAE,IAAI,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
|
+
* Params for name-addressed agent ops (`agent.lookup`, `agent.unregister`).
|
|
4
|
+
* Exact registered name — partial/fuzzy matching stays client-side.
|
|
5
|
+
*/ export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgentRenameParams.d.ts","sourceRoot":"","sources":["../../src/gen/AgentRenameParams.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;CAAE,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `agent.rename` result. `runtimeRenamed` is false when there was no live
|
|
3
|
+
* runtime handle to rename (tmux session gone, dead herdr agent) — the
|
|
4
|
+
* registry-only case, explained in `warnings`.
|
|
5
|
+
*/
|
|
6
|
+
export type AgentRenameResult = {
|
|
7
|
+
from: string;
|
|
8
|
+
to: string;
|
|
9
|
+
pid: number;
|
|
10
|
+
runtime: string;
|
|
11
|
+
/**
|
|
12
|
+
* Updated provider handle (tmux `session` / herdr `agentName` = `to`).
|
|
13
|
+
*/
|
|
14
|
+
runtimeRef: unknown;
|
|
15
|
+
runtimeRenamed: boolean;
|
|
16
|
+
warnings: Array<string>;
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=AgentRenameResult.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgentRenameResult.d.ts","sourceRoot":"","sources":["../../src/gen/AgentRenameResult.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IACzF;;OAEG;IACH,UAAU,EAAE,OAAO,CAAC;IAAC,cAAc,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;CAAE,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
|
2
|
+
/**
|
|
3
|
+
* `agent.rename` result. `runtimeRenamed` is false when there was no live
|
|
4
|
+
* runtime handle to rename (tmux session gone, dead herdr agent) — the
|
|
5
|
+
* registry-only case, explained in `warnings`.
|
|
6
|
+
*/ export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgentUnregisterResult.d.ts","sourceRoot":"","sources":["../../src/gen/AgentUnregisterResult.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;CAAE,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,11 @@ export { DaemonClient, daemonSocketPath, DaemonRpcError } from "./client.js";
|
|
|
2
2
|
export type { DaemonEvent } from "./client.js";
|
|
3
3
|
export type { AgentStartParams } from "./gen/AgentStartParams.js";
|
|
4
4
|
export type { AgentStartResult } from "./gen/AgentStartResult.js";
|
|
5
|
+
export type { AgentLookupResult } from "./gen/AgentLookupResult.js";
|
|
6
|
+
export type { AgentNameParams } from "./gen/AgentNameParams.js";
|
|
7
|
+
export type { AgentUnregisterResult } from "./gen/AgentUnregisterResult.js";
|
|
8
|
+
export type { AgentRenameParams } from "./gen/AgentRenameParams.js";
|
|
9
|
+
export type { AgentRenameResult } from "./gen/AgentRenameResult.js";
|
|
5
10
|
export type { EnrichedAgent, Event } from "./gen/index.js";
|
|
6
11
|
export { resolveDaemonBinary } from "./binary.js";
|
|
7
12
|
export { ensureDaemon } from "./autostart.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7E,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,YAAY,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClE,YAAY,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClE,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"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7E,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,YAAY,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClE,YAAY,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClE,YAAY,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACpE,YAAY,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAChE,YAAY,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAC5E,YAAY,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACpE,YAAY,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACpE,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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-devkit/daemon-client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Thin client for the devkitd coordination daemon (unix socket, JSON-RPC, subscribe)",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -38,9 +38,9 @@
|
|
|
38
38
|
"vitest": "^4.1.8"
|
|
39
39
|
},
|
|
40
40
|
"optionalDependencies": {
|
|
41
|
-
"@ai-devkit/devkitd-darwin-arm64": "0.
|
|
42
|
-
"@ai-devkit/devkitd-darwin-x64": "0.
|
|
43
|
-
"@ai-devkit/devkitd-linux-arm64": "0.
|
|
44
|
-
"@ai-devkit/devkitd-linux-x64": "0.
|
|
41
|
+
"@ai-devkit/devkitd-darwin-arm64": "0.3.0",
|
|
42
|
+
"@ai-devkit/devkitd-darwin-x64": "0.3.0",
|
|
43
|
+
"@ai-devkit/devkitd-linux-arm64": "0.3.0",
|
|
44
|
+
"@ai-devkit/devkitd-linux-x64": "0.3.0"
|
|
45
45
|
}
|
|
46
46
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"daemon-sweep.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/daemon-sweep.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,356 +0,0 @@
|
|
|
1
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
2
|
-
try {
|
|
3
|
-
var info = gen[key](arg);
|
|
4
|
-
var value = info.value;
|
|
5
|
-
} catch (error) {
|
|
6
|
-
reject(error);
|
|
7
|
-
return;
|
|
8
|
-
}
|
|
9
|
-
if (info.done) {
|
|
10
|
-
resolve(value);
|
|
11
|
-
} else {
|
|
12
|
-
Promise.resolve(value).then(_next, _throw);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
function _async_to_generator(fn) {
|
|
16
|
-
return function() {
|
|
17
|
-
var self = this, args = arguments;
|
|
18
|
-
return new Promise(function(resolve, reject) {
|
|
19
|
-
var gen = fn.apply(self, args);
|
|
20
|
-
function _next(value) {
|
|
21
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
22
|
-
}
|
|
23
|
-
function _throw(err) {
|
|
24
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
25
|
-
}
|
|
26
|
-
_next(undefined);
|
|
27
|
-
});
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
function _define_property(obj, key, value) {
|
|
31
|
-
if (key in obj) {
|
|
32
|
-
Object.defineProperty(obj, key, {
|
|
33
|
-
value: value,
|
|
34
|
-
enumerable: true,
|
|
35
|
-
configurable: true,
|
|
36
|
-
writable: true
|
|
37
|
-
});
|
|
38
|
-
} else {
|
|
39
|
-
obj[key] = value;
|
|
40
|
-
}
|
|
41
|
-
return obj;
|
|
42
|
-
}
|
|
43
|
-
function _object_spread(target) {
|
|
44
|
-
for(var i = 1; i < arguments.length; i++){
|
|
45
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
|
46
|
-
var ownKeys = Object.keys(source);
|
|
47
|
-
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
48
|
-
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
49
|
-
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
50
|
-
}));
|
|
51
|
-
}
|
|
52
|
-
ownKeys.forEach(function(key) {
|
|
53
|
-
_define_property(target, key, source[key]);
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
return target;
|
|
57
|
-
}
|
|
58
|
-
function ownKeys(object, enumerableOnly) {
|
|
59
|
-
var keys = Object.keys(object);
|
|
60
|
-
if (Object.getOwnPropertySymbols) {
|
|
61
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
62
|
-
if (enumerableOnly) {
|
|
63
|
-
symbols = symbols.filter(function(sym) {
|
|
64
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
keys.push.apply(keys, symbols);
|
|
68
|
-
}
|
|
69
|
-
return keys;
|
|
70
|
-
}
|
|
71
|
-
function _object_spread_props(target, source) {
|
|
72
|
-
source = source != null ? source : {};
|
|
73
|
-
if (Object.getOwnPropertyDescriptors) {
|
|
74
|
-
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
75
|
-
} else {
|
|
76
|
-
ownKeys(Object(source)).forEach(function(key) {
|
|
77
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
return target;
|
|
81
|
-
}
|
|
82
|
-
function _ts_generator(thisArg, body) {
|
|
83
|
-
var f, y, t, _ = {
|
|
84
|
-
label: 0,
|
|
85
|
-
sent: function() {
|
|
86
|
-
if (t[0] & 1) throw t[1];
|
|
87
|
-
return t[1];
|
|
88
|
-
},
|
|
89
|
-
trys: [],
|
|
90
|
-
ops: []
|
|
91
|
-
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
92
|
-
return d(g, "next", {
|
|
93
|
-
value: verb(0)
|
|
94
|
-
}), d(g, "throw", {
|
|
95
|
-
value: verb(1)
|
|
96
|
-
}), d(g, "return", {
|
|
97
|
-
value: verb(2)
|
|
98
|
-
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
99
|
-
value: function() {
|
|
100
|
-
return this;
|
|
101
|
-
}
|
|
102
|
-
}), g;
|
|
103
|
-
function verb(n) {
|
|
104
|
-
return function(v) {
|
|
105
|
-
return step([
|
|
106
|
-
n,
|
|
107
|
-
v
|
|
108
|
-
]);
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
function step(op) {
|
|
112
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
113
|
-
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
114
|
-
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;
|
|
115
|
-
if (y = 0, t) op = [
|
|
116
|
-
op[0] & 2,
|
|
117
|
-
t.value
|
|
118
|
-
];
|
|
119
|
-
switch(op[0]){
|
|
120
|
-
case 0:
|
|
121
|
-
case 1:
|
|
122
|
-
t = op;
|
|
123
|
-
break;
|
|
124
|
-
case 4:
|
|
125
|
-
_.label++;
|
|
126
|
-
return {
|
|
127
|
-
value: op[1],
|
|
128
|
-
done: false
|
|
129
|
-
};
|
|
130
|
-
case 5:
|
|
131
|
-
_.label++;
|
|
132
|
-
y = op[1];
|
|
133
|
-
op = [
|
|
134
|
-
0
|
|
135
|
-
];
|
|
136
|
-
continue;
|
|
137
|
-
case 7:
|
|
138
|
-
op = _.ops.pop();
|
|
139
|
-
_.trys.pop();
|
|
140
|
-
continue;
|
|
141
|
-
default:
|
|
142
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
143
|
-
_ = 0;
|
|
144
|
-
continue;
|
|
145
|
-
}
|
|
146
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
147
|
-
_.label = op[1];
|
|
148
|
-
break;
|
|
149
|
-
}
|
|
150
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
151
|
-
_.label = t[1];
|
|
152
|
-
t = op;
|
|
153
|
-
break;
|
|
154
|
-
}
|
|
155
|
-
if (t && _.label < t[2]) {
|
|
156
|
-
_.label = t[2];
|
|
157
|
-
_.ops.push(op);
|
|
158
|
-
break;
|
|
159
|
-
}
|
|
160
|
-
if (t[2]) _.ops.pop();
|
|
161
|
-
_.trys.pop();
|
|
162
|
-
continue;
|
|
163
|
-
}
|
|
164
|
-
op = body.call(thisArg, _);
|
|
165
|
-
} catch (e) {
|
|
166
|
-
op = [
|
|
167
|
-
6,
|
|
168
|
-
e
|
|
169
|
-
];
|
|
170
|
-
y = 0;
|
|
171
|
-
} finally{
|
|
172
|
-
f = t = 0;
|
|
173
|
-
}
|
|
174
|
-
if (op[0] & 5) throw op[1];
|
|
175
|
-
return {
|
|
176
|
-
value: op[0] ? op[1] : void 0,
|
|
177
|
-
done: true
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
var _ref, _process_env_DEVKITD_BIN;
|
|
182
|
-
import { describe, it, expect, beforeAll, afterAll } from "vitest";
|
|
183
|
-
import { spawn } from "node:child_process";
|
|
184
|
-
import * as fs from "node:fs";
|
|
185
|
-
import * as os from "node:os";
|
|
186
|
-
import * as path from "node:path";
|
|
187
|
-
import { DaemonClient } from "../client.js";
|
|
188
|
-
var repoRoot = path.resolve(path.dirname(new URL(import.meta.url).pathname), "../../../..");
|
|
189
|
-
var devBin = [
|
|
190
|
-
path.join(repoRoot, "rust/target/release/devkitd"),
|
|
191
|
-
path.join(repoRoot, "rust/target/debug/devkitd")
|
|
192
|
-
].find(function(p) {
|
|
193
|
-
return fs.existsSync(p);
|
|
194
|
-
});
|
|
195
|
-
var bin = (_ref = (_process_env_DEVKITD_BIN = process.env.DEVKITD_BIN) !== null && _process_env_DEVKITD_BIN !== void 0 ? _process_env_DEVKITD_BIN : process.env.AI_DEVKITD_BIN) !== null && _ref !== void 0 ? _ref : devBin;
|
|
196
|
-
/**
|
|
197
|
-
* Issue #371 regression coverage at the daemon boundary: a stub `ps` on
|
|
198
|
-
* PATH feeds devkitd synthetic procps output with PADDED columns — the
|
|
199
|
-
* exact shape that used to make every row unparseable, leaving
|
|
200
|
-
* `agent.list` permanently empty. Skipped when no devkitd binary exists
|
|
201
|
-
* (CI builds it in the test job).
|
|
202
|
-
*/ describe.runIf(bin != null && process.platform !== "win32")("devkitd sweep with stub ps", function() {
|
|
203
|
-
var home;
|
|
204
|
-
var stubDir;
|
|
205
|
-
var sock;
|
|
206
|
-
var daemon = null;
|
|
207
|
-
var PADDED_PS = " 424242 1 pts/1 claude\n 424243 424242 pts/2 gemini\n";
|
|
208
|
-
beforeAll(function() {
|
|
209
|
-
return _async_to_generator(function() {
|
|
210
|
-
var stub, deadline;
|
|
211
|
-
return _ts_generator(this, function(_state) {
|
|
212
|
-
switch(_state.label){
|
|
213
|
-
case 0:
|
|
214
|
-
home = fs.mkdtempSync(path.join(os.tmpdir(), "devkitd-ps-e2e-"));
|
|
215
|
-
stubDir = path.join(home, "stub-bin");
|
|
216
|
-
fs.mkdirSync(stubDir);
|
|
217
|
-
stub = path.join(stubDir, "ps");
|
|
218
|
-
fs.writeFileSync(stub, "#!/bin/sh\nprintf '%s' '".concat(PADDED_PS, "'\n"));
|
|
219
|
-
fs.chmodSync(stub, 493);
|
|
220
|
-
sock = path.join(home, ".ai-devkit", "daemon.sock");
|
|
221
|
-
daemon = spawn(bin, [
|
|
222
|
-
"serve"
|
|
223
|
-
], {
|
|
224
|
-
env: _object_spread_props(_object_spread({}, process.env), {
|
|
225
|
-
HOME: home,
|
|
226
|
-
PATH: "".concat(stubDir).concat(path.delimiter).concat(process.env.PATH),
|
|
227
|
-
RUST_LOG: "warn"
|
|
228
|
-
}),
|
|
229
|
-
stdio: "ignore"
|
|
230
|
-
});
|
|
231
|
-
daemon.unref();
|
|
232
|
-
deadline = Date.now() + 10000;
|
|
233
|
-
_state.label = 1;
|
|
234
|
-
case 1:
|
|
235
|
-
if (!!fs.existsSync(sock)) return [
|
|
236
|
-
3,
|
|
237
|
-
3
|
|
238
|
-
];
|
|
239
|
-
if (daemon.exitCode !== null) throw new Error("devkitd exited before binding its socket");
|
|
240
|
-
if (Date.now() > deadline) throw new Error("timed out waiting for daemon socket");
|
|
241
|
-
return [
|
|
242
|
-
4,
|
|
243
|
-
new Promise(function(r) {
|
|
244
|
-
return setTimeout(r, 50);
|
|
245
|
-
})
|
|
246
|
-
];
|
|
247
|
-
case 2:
|
|
248
|
-
_state.sent();
|
|
249
|
-
return [
|
|
250
|
-
3,
|
|
251
|
-
1
|
|
252
|
-
];
|
|
253
|
-
case 3:
|
|
254
|
-
return [
|
|
255
|
-
2
|
|
256
|
-
];
|
|
257
|
-
}
|
|
258
|
-
});
|
|
259
|
-
})();
|
|
260
|
-
}, 15000);
|
|
261
|
-
afterAll(function() {
|
|
262
|
-
return _async_to_generator(function() {
|
|
263
|
-
var c;
|
|
264
|
-
return _ts_generator(this, function(_state) {
|
|
265
|
-
switch(_state.label){
|
|
266
|
-
case 0:
|
|
267
|
-
if (!daemon) return [
|
|
268
|
-
3,
|
|
269
|
-
4
|
|
270
|
-
];
|
|
271
|
-
return [
|
|
272
|
-
4,
|
|
273
|
-
DaemonClient.tryConnect(sock).catch(function() {
|
|
274
|
-
return null;
|
|
275
|
-
})
|
|
276
|
-
];
|
|
277
|
-
case 1:
|
|
278
|
-
c = _state.sent();
|
|
279
|
-
if (!c) return [
|
|
280
|
-
3,
|
|
281
|
-
3
|
|
282
|
-
];
|
|
283
|
-
return [
|
|
284
|
-
4,
|
|
285
|
-
c.request("shutdown").catch(function() {})
|
|
286
|
-
];
|
|
287
|
-
case 2:
|
|
288
|
-
_state.sent();
|
|
289
|
-
c.close();
|
|
290
|
-
_state.label = 3;
|
|
291
|
-
case 3:
|
|
292
|
-
daemon.kill("SIGKILL");
|
|
293
|
-
_state.label = 4;
|
|
294
|
-
case 4:
|
|
295
|
-
fs.rmSync(home, {
|
|
296
|
-
recursive: true,
|
|
297
|
-
force: true
|
|
298
|
-
});
|
|
299
|
-
return [
|
|
300
|
-
2
|
|
301
|
-
];
|
|
302
|
-
}
|
|
303
|
-
});
|
|
304
|
-
})();
|
|
305
|
-
});
|
|
306
|
-
it("agent.list reports agents from padded procps rows", function() {
|
|
307
|
-
return _async_to_generator(function() {
|
|
308
|
-
var client, _agents_find, agents, pids;
|
|
309
|
-
return _ts_generator(this, function(_state) {
|
|
310
|
-
switch(_state.label){
|
|
311
|
-
case 0:
|
|
312
|
-
return [
|
|
313
|
-
4,
|
|
314
|
-
DaemonClient.connect(sock)
|
|
315
|
-
];
|
|
316
|
-
case 1:
|
|
317
|
-
client = _state.sent();
|
|
318
|
-
_state.label = 2;
|
|
319
|
-
case 2:
|
|
320
|
-
_state.trys.push([
|
|
321
|
-
2,
|
|
322
|
-
,
|
|
323
|
-
4,
|
|
324
|
-
5
|
|
325
|
-
]);
|
|
326
|
-
return [
|
|
327
|
-
4,
|
|
328
|
-
client.listAgents()
|
|
329
|
-
];
|
|
330
|
-
case 3:
|
|
331
|
-
agents = _state.sent();
|
|
332
|
-
pids = agents.map(function(a) {
|
|
333
|
-
return a.pid;
|
|
334
|
-
});
|
|
335
|
-
expect(pids).toContain(424242);
|
|
336
|
-
expect((_agents_find = agents.find(function(a) {
|
|
337
|
-
return a.pid === 424242;
|
|
338
|
-
})) === null || _agents_find === void 0 ? void 0 : _agents_find.type).toBe("claude");
|
|
339
|
-
return [
|
|
340
|
-
3,
|
|
341
|
-
5
|
|
342
|
-
];
|
|
343
|
-
case 4:
|
|
344
|
-
client.close();
|
|
345
|
-
return [
|
|
346
|
-
7
|
|
347
|
-
];
|
|
348
|
-
case 5:
|
|
349
|
-
return [
|
|
350
|
-
2
|
|
351
|
-
];
|
|
352
|
-
}
|
|
353
|
-
});
|
|
354
|
-
})();
|
|
355
|
-
}, 15000);
|
|
356
|
-
});
|