@actiondock/core 2.4.0 → 2.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/dist/profile/client.d.ts +39 -56
- package/dist/profile/client.js +117 -35
- package/dist/profile/manager.d.ts +3 -0
- package/dist/profile/manager.js +47 -0
- package/dist/profile/types.d.ts +6 -0
- package/dist/project/init.js +2 -2
- package/dist/server/dispatcher.d.ts +24 -0
- package/dist/server/dispatcher.js +86 -0
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +1 -0
- package/dist/server/server.d.ts +2 -2
- package/dist/server/server.js +35 -7
- package/dist/server/types.d.ts +17 -0
- package/dist/target/remote.d.ts +6 -0
- package/dist/target/remote.js +181 -16
- package/dist/target/types.d.ts +9 -0
- package/dist/target/types.js +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
package/dist/target/remote.js
CHANGED
|
@@ -2,13 +2,17 @@ import { ActionResolver } from "../catalog/action-resolver.js";
|
|
|
2
2
|
import { cancelRemoteRun, clearRemoteRuns, clearRemoteState, deleteRemoteConfig, deleteRemoteStateKey, executeRemoteAction, fetchRemoteActionShow, fetchRemoteActions, fetchRemoteConfig, fetchRemoteInfo, fetchRemotePlaybookShow, fetchRemotePlaybooks, fetchRemoteRun, fetchRemoteRuns, fetchRemoteStateList, getRemoteStateKey, setRemoteConfig, setRemoteStateKey, assertSecureTransport, } from "../profile/client.js";
|
|
3
3
|
import { normalizeServerUrl } from "../profile/manager.js";
|
|
4
4
|
import { isTerminalRunStatus } from "../storage/types.js";
|
|
5
|
-
import { ACTIONDOCK_PROTOCOL_VERSION, TargetError, TARGET_PROTOCOL_UNSUPPORTED, TARGET_CAPABILITY_UNAVAILABLE, TARGET_RESULT_UNKNOWN, } from "./types.js";
|
|
5
|
+
import { ACTIONDOCK_PROTOCOL_VERSION, TargetError, TARGET_PROTOCOL_UNSUPPORTED, TARGET_CAPABILITY_UNAVAILABLE, TARGET_RESULT_UNKNOWN, TARGET_CLOSED, } from "./types.js";
|
|
6
6
|
import { ACTION_CANCELLED, EXECUTION_FAILED, STATE_KEY_NOT_FOUND, TIMEOUT } from "../errors.js";
|
|
7
|
+
import { getInsecureDispatcher } from "../server/dispatcher.js";
|
|
7
8
|
/**
|
|
8
9
|
* 读取并解析远端 SSE 事件流。
|
|
9
10
|
*/
|
|
10
11
|
export async function* streamRemoteEvents(serverUrl, runId, token, options) {
|
|
11
|
-
assertSecureTransport(serverUrl, token,
|
|
12
|
+
assertSecureTransport(serverUrl, token, {
|
|
13
|
+
allowInsecureHttp: options?.allowInsecureHttp,
|
|
14
|
+
insecure: options?.insecure,
|
|
15
|
+
});
|
|
12
16
|
const base = normalizeServerUrl(serverUrl);
|
|
13
17
|
const candidateUrls = [
|
|
14
18
|
`${base}/api/v2/runs/${encodeURIComponent(runId)}/events`,
|
|
@@ -27,10 +31,17 @@ export async function* streamRemoteEvents(serverUrl, runId, token, options) {
|
|
|
27
31
|
let res;
|
|
28
32
|
for (const url of candidateUrls) {
|
|
29
33
|
try {
|
|
30
|
-
const
|
|
34
|
+
const fetchInit = {
|
|
31
35
|
headers,
|
|
32
36
|
signal: options?.signal,
|
|
33
|
-
}
|
|
37
|
+
};
|
|
38
|
+
if (options?.dispatcher) {
|
|
39
|
+
fetchInit.dispatcher = options.dispatcher;
|
|
40
|
+
}
|
|
41
|
+
else if (options?.insecure) {
|
|
42
|
+
fetchInit.dispatcher = getInsecureDispatcher();
|
|
43
|
+
}
|
|
44
|
+
const resp = await fetch(url, fetchInit);
|
|
34
45
|
if (resp.status === 410) {
|
|
35
46
|
let errJson;
|
|
36
47
|
try {
|
|
@@ -238,18 +249,31 @@ export class RemoteActionDockTarget {
|
|
|
238
249
|
timeoutMs;
|
|
239
250
|
baseTimeoutMs;
|
|
240
251
|
allowInsecureHttp;
|
|
252
|
+
insecure;
|
|
253
|
+
dispatcher;
|
|
254
|
+
isClosed = false;
|
|
241
255
|
constructor(options) {
|
|
242
256
|
this.serverUrl = options.serverUrl;
|
|
243
257
|
this.token = options.token;
|
|
244
258
|
this.timeoutMs = options.timeoutMs;
|
|
245
259
|
this.baseTimeoutMs = options.baseTimeoutMs ?? 60000;
|
|
246
260
|
this.allowInsecureHttp = options.allowInsecureHttp;
|
|
261
|
+
this.insecure = options.insecure;
|
|
262
|
+
this.dispatcher = options.dispatcher;
|
|
263
|
+
}
|
|
264
|
+
assertNotClosed() {
|
|
265
|
+
if (this.isClosed) {
|
|
266
|
+
throw new TargetError(TARGET_CLOSED, "RemoteActionDockTarget is closed");
|
|
267
|
+
}
|
|
247
268
|
}
|
|
248
269
|
async info() {
|
|
270
|
+
this.assertNotClosed();
|
|
249
271
|
let raw;
|
|
250
272
|
try {
|
|
251
273
|
raw = await fetchRemoteInfo(this.serverUrl, this.token, {
|
|
252
274
|
allowInsecureHttp: this.allowInsecureHttp,
|
|
275
|
+
insecure: this.insecure,
|
|
276
|
+
dispatcher: this.dispatcher,
|
|
253
277
|
});
|
|
254
278
|
}
|
|
255
279
|
catch (err) {
|
|
@@ -287,12 +311,16 @@ export class RemoteActionDockTarget {
|
|
|
287
311
|
};
|
|
288
312
|
}
|
|
289
313
|
async listPackages() {
|
|
314
|
+
this.assertNotClosed();
|
|
290
315
|
const info = await this.info();
|
|
291
316
|
return info.packages;
|
|
292
317
|
}
|
|
293
318
|
async listActions(options) {
|
|
319
|
+
this.assertNotClosed();
|
|
294
320
|
const rawList = await fetchRemoteActions(this.serverUrl, this.token, options?.query, {
|
|
295
321
|
allowInsecureHttp: this.allowInsecureHttp,
|
|
322
|
+
insecure: this.insecure,
|
|
323
|
+
dispatcher: this.dispatcher,
|
|
296
324
|
});
|
|
297
325
|
let summaries = rawList.map((item) => ({
|
|
298
326
|
id: item.id,
|
|
@@ -311,6 +339,7 @@ export class RemoteActionDockTarget {
|
|
|
311
339
|
return summaries;
|
|
312
340
|
}
|
|
313
341
|
async describeAction(ref) {
|
|
342
|
+
this.assertNotClosed();
|
|
314
343
|
let parsed;
|
|
315
344
|
try {
|
|
316
345
|
parsed = ActionResolver.parseRef(ref);
|
|
@@ -323,6 +352,8 @@ export class RemoteActionDockTarget {
|
|
|
323
352
|
: parsed.actionId;
|
|
324
353
|
const raw = await fetchRemoteActionShow(this.serverUrl, actionId, this.token, {
|
|
325
354
|
allowInsecureHttp: this.allowInsecureHttp,
|
|
355
|
+
insecure: this.insecure,
|
|
356
|
+
dispatcher: this.dispatcher,
|
|
326
357
|
});
|
|
327
358
|
return {
|
|
328
359
|
id: raw.id,
|
|
@@ -338,9 +369,12 @@ export class RemoteActionDockTarget {
|
|
|
338
369
|
};
|
|
339
370
|
}
|
|
340
371
|
async listPlaybooks(options) {
|
|
372
|
+
this.assertNotClosed();
|
|
341
373
|
const rawList = await fetchRemotePlaybooks(this.serverUrl, this.token, {
|
|
342
374
|
...options,
|
|
343
375
|
allowInsecureHttp: this.allowInsecureHttp,
|
|
376
|
+
insecure: this.insecure,
|
|
377
|
+
dispatcher: this.dispatcher,
|
|
344
378
|
});
|
|
345
379
|
return rawList.map((item) => ({
|
|
346
380
|
id: item.id,
|
|
@@ -351,8 +385,11 @@ export class RemoteActionDockTarget {
|
|
|
351
385
|
}));
|
|
352
386
|
}
|
|
353
387
|
async describePlaybook(id) {
|
|
388
|
+
this.assertNotClosed();
|
|
354
389
|
const raw = await fetchRemotePlaybookShow(this.serverUrl, id, this.token, {
|
|
355
390
|
allowInsecureHttp: this.allowInsecureHttp,
|
|
391
|
+
insecure: this.insecure,
|
|
392
|
+
dispatcher: this.dispatcher,
|
|
356
393
|
});
|
|
357
394
|
const parsedPkgId = id.includes("/") ? id.slice(0, id.lastIndexOf("/")) : undefined;
|
|
358
395
|
return {
|
|
@@ -365,6 +402,7 @@ export class RemoteActionDockTarget {
|
|
|
365
402
|
};
|
|
366
403
|
}
|
|
367
404
|
async runAction(ref, input, options) {
|
|
405
|
+
this.assertNotClosed();
|
|
368
406
|
let parsed;
|
|
369
407
|
try {
|
|
370
408
|
parsed = ActionResolver.parseRef(ref);
|
|
@@ -383,9 +421,12 @@ export class RemoteActionDockTarget {
|
|
|
383
421
|
requestId: options?.requestId,
|
|
384
422
|
async: false,
|
|
385
423
|
allowInsecureHttp: this.allowInsecureHttp,
|
|
424
|
+
insecure: this.insecure,
|
|
425
|
+
dispatcher: this.dispatcher,
|
|
386
426
|
});
|
|
387
427
|
}
|
|
388
428
|
async startAction(ref, input, options) {
|
|
429
|
+
this.assertNotClosed();
|
|
389
430
|
let parsed;
|
|
390
431
|
try {
|
|
391
432
|
parsed = ActionResolver.parseRef(ref);
|
|
@@ -404,6 +445,8 @@ export class RemoteActionDockTarget {
|
|
|
404
445
|
requestId: options?.requestId,
|
|
405
446
|
async: true,
|
|
406
447
|
allowInsecureHttp: this.allowInsecureHttp,
|
|
448
|
+
insecure: this.insecure,
|
|
449
|
+
dispatcher: this.dispatcher,
|
|
407
450
|
});
|
|
408
451
|
if (!res.ok) {
|
|
409
452
|
return {
|
|
@@ -440,6 +483,16 @@ export class RemoteActionDockTarget {
|
|
|
440
483
|
},
|
|
441
484
|
};
|
|
442
485
|
}
|
|
486
|
+
if (this.isClosed) {
|
|
487
|
+
return {
|
|
488
|
+
ok: false,
|
|
489
|
+
runId,
|
|
490
|
+
error: {
|
|
491
|
+
code: TARGET_CLOSED,
|
|
492
|
+
message: "RemoteActionDockTarget is closed",
|
|
493
|
+
},
|
|
494
|
+
};
|
|
495
|
+
}
|
|
443
496
|
const internalController = new AbortController();
|
|
444
497
|
let sseTimedOut = false;
|
|
445
498
|
let timer;
|
|
@@ -467,6 +520,16 @@ export class RemoteActionDockTarget {
|
|
|
467
520
|
}
|
|
468
521
|
}
|
|
469
522
|
catch (err) {
|
|
523
|
+
if (err?.code === TARGET_CLOSED || this.isClosed) {
|
|
524
|
+
return {
|
|
525
|
+
ok: false,
|
|
526
|
+
runId,
|
|
527
|
+
error: {
|
|
528
|
+
code: TARGET_CLOSED,
|
|
529
|
+
message: "RemoteActionDockTarget is closed",
|
|
530
|
+
},
|
|
531
|
+
};
|
|
532
|
+
}
|
|
470
533
|
if (!signal?.aborted && !sseTimedOut) {
|
|
471
534
|
// SSE 通道异常视为不可用:记录后按指数退避进入轮询兜底
|
|
472
535
|
console.warn(`[ActionDock] SSE event stream unavailable for run '${runId}', falling back to polling: ${err?.message || String(err)}`);
|
|
@@ -492,9 +555,34 @@ export class RemoteActionDockTarget {
|
|
|
492
555
|
}
|
|
493
556
|
const remainingWaitMs = Math.max(0, maxWaitMs - (Date.now() - startTime));
|
|
494
557
|
if (remainingWaitMs <= 0) {
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
558
|
+
if (this.isClosed) {
|
|
559
|
+
return {
|
|
560
|
+
ok: false,
|
|
561
|
+
runId,
|
|
562
|
+
error: {
|
|
563
|
+
code: TARGET_CLOSED,
|
|
564
|
+
message: "RemoteActionDockTarget is closed",
|
|
565
|
+
},
|
|
566
|
+
};
|
|
567
|
+
}
|
|
568
|
+
try {
|
|
569
|
+
const run = await this.getRun(runId);
|
|
570
|
+
if (run && isTerminalRunStatus(run.status)) {
|
|
571
|
+
return this.formatTerminalRunResult(run, runId);
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
catch (err) {
|
|
575
|
+
if (err?.code === TARGET_CLOSED || this.isClosed) {
|
|
576
|
+
return {
|
|
577
|
+
ok: false,
|
|
578
|
+
runId,
|
|
579
|
+
error: {
|
|
580
|
+
code: TARGET_CLOSED,
|
|
581
|
+
message: "RemoteActionDockTarget is closed",
|
|
582
|
+
},
|
|
583
|
+
};
|
|
584
|
+
}
|
|
585
|
+
throw err;
|
|
498
586
|
}
|
|
499
587
|
const waitedMs = Date.now() - startTime;
|
|
500
588
|
return {
|
|
@@ -518,6 +606,16 @@ export class RemoteActionDockTarget {
|
|
|
518
606
|
let delayMs = Math.min(150, Math.max(10, Math.floor((remainingWaitMs || maxWaitMs) / 4)));
|
|
519
607
|
const maxDelayMs = 2000;
|
|
520
608
|
while (Date.now() - startTime < maxWaitMs) {
|
|
609
|
+
if (this.isClosed) {
|
|
610
|
+
return {
|
|
611
|
+
ok: false,
|
|
612
|
+
runId,
|
|
613
|
+
error: {
|
|
614
|
+
code: TARGET_CLOSED,
|
|
615
|
+
message: "RemoteActionDockTarget is closed",
|
|
616
|
+
},
|
|
617
|
+
};
|
|
618
|
+
}
|
|
521
619
|
if (signal?.aborted) {
|
|
522
620
|
return {
|
|
523
621
|
ok: false,
|
|
@@ -528,9 +626,24 @@ export class RemoteActionDockTarget {
|
|
|
528
626
|
},
|
|
529
627
|
};
|
|
530
628
|
}
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
629
|
+
try {
|
|
630
|
+
const run = await this.getRun(runId);
|
|
631
|
+
if (run && isTerminalRunStatus(run.status)) {
|
|
632
|
+
return this.formatTerminalRunResult(run, runId);
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
catch (err) {
|
|
636
|
+
if (err?.code === TARGET_CLOSED || this.isClosed) {
|
|
637
|
+
return {
|
|
638
|
+
ok: false,
|
|
639
|
+
runId,
|
|
640
|
+
error: {
|
|
641
|
+
code: TARGET_CLOSED,
|
|
642
|
+
message: "RemoteActionDockTarget is closed",
|
|
643
|
+
},
|
|
644
|
+
};
|
|
645
|
+
}
|
|
646
|
+
throw err;
|
|
534
647
|
}
|
|
535
648
|
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
536
649
|
delayMs = Math.min(delayMs * 2, maxDelayMs);
|
|
@@ -569,6 +682,7 @@ export class RemoteActionDockTarget {
|
|
|
569
682
|
};
|
|
570
683
|
}
|
|
571
684
|
async listRuns(options) {
|
|
685
|
+
this.assertNotClosed();
|
|
572
686
|
try {
|
|
573
687
|
const res = await fetchRemoteRuns(this.serverUrl, this.token, {
|
|
574
688
|
packageId: options?.packageId,
|
|
@@ -577,6 +691,8 @@ export class RemoteActionDockTarget {
|
|
|
577
691
|
intent: options?.intent,
|
|
578
692
|
limit: options?.limit,
|
|
579
693
|
allowInsecureHttp: this.allowInsecureHttp,
|
|
694
|
+
insecure: this.insecure,
|
|
695
|
+
dispatcher: this.dispatcher,
|
|
580
696
|
});
|
|
581
697
|
return res.items || [];
|
|
582
698
|
}
|
|
@@ -585,10 +701,13 @@ export class RemoteActionDockTarget {
|
|
|
585
701
|
}
|
|
586
702
|
}
|
|
587
703
|
async clearRuns(options) {
|
|
704
|
+
this.assertNotClosed();
|
|
588
705
|
try {
|
|
589
706
|
const res = await clearRemoteRuns(this.serverUrl, this.token, {
|
|
590
707
|
...options,
|
|
591
708
|
allowInsecureHttp: this.allowInsecureHttp,
|
|
709
|
+
insecure: this.insecure,
|
|
710
|
+
dispatcher: this.dispatcher,
|
|
592
711
|
});
|
|
593
712
|
return res.clearedCount ?? 0;
|
|
594
713
|
}
|
|
@@ -597,9 +716,12 @@ export class RemoteActionDockTarget {
|
|
|
597
716
|
}
|
|
598
717
|
}
|
|
599
718
|
async getRun(runId) {
|
|
719
|
+
this.assertNotClosed();
|
|
600
720
|
try {
|
|
601
721
|
return await fetchRemoteRun(this.serverUrl, runId, this.token, {
|
|
602
722
|
allowInsecureHttp: this.allowInsecureHttp,
|
|
723
|
+
insecure: this.insecure,
|
|
724
|
+
dispatcher: this.dispatcher,
|
|
603
725
|
});
|
|
604
726
|
}
|
|
605
727
|
catch (err) {
|
|
@@ -611,9 +733,12 @@ export class RemoteActionDockTarget {
|
|
|
611
733
|
}
|
|
612
734
|
}
|
|
613
735
|
async cancelRun(runId, reason) {
|
|
736
|
+
this.assertNotClosed();
|
|
614
737
|
try {
|
|
615
738
|
const res = await cancelRemoteRun(this.serverUrl, runId, this.token, reason, {
|
|
616
739
|
allowInsecureHttp: this.allowInsecureHttp,
|
|
740
|
+
insecure: this.insecure,
|
|
741
|
+
dispatcher: this.dispatcher,
|
|
617
742
|
});
|
|
618
743
|
return { outcome: "requested", runId: res.runId };
|
|
619
744
|
}
|
|
@@ -644,13 +769,25 @@ export class RemoteActionDockTarget {
|
|
|
644
769
|
throw err;
|
|
645
770
|
}
|
|
646
771
|
}
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
772
|
+
events(runId, options) {
|
|
773
|
+
this.assertNotClosed();
|
|
774
|
+
const self = this;
|
|
775
|
+
async function* stream() {
|
|
776
|
+
self.assertNotClosed();
|
|
777
|
+
for await (const event of streamRemoteEvents(self.serverUrl, runId, self.token, {
|
|
778
|
+
...options,
|
|
779
|
+
allowInsecureHttp: self.allowInsecureHttp,
|
|
780
|
+
insecure: self.insecure,
|
|
781
|
+
dispatcher: self.dispatcher,
|
|
782
|
+
})) {
|
|
783
|
+
self.assertNotClosed();
|
|
784
|
+
yield event;
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
return stream();
|
|
652
788
|
}
|
|
653
789
|
async getConfig(packageId, key) {
|
|
790
|
+
this.assertNotClosed();
|
|
654
791
|
try {
|
|
655
792
|
const list = await this.listConfig(packageId);
|
|
656
793
|
const found = list.find((c) => c.key === key);
|
|
@@ -670,9 +807,12 @@ export class RemoteActionDockTarget {
|
|
|
670
807
|
}
|
|
671
808
|
}
|
|
672
809
|
async setConfig(packageId, key, value) {
|
|
810
|
+
this.assertNotClosed();
|
|
673
811
|
try {
|
|
674
812
|
await setRemoteConfig(this.serverUrl, key, value, this.token, packageId || undefined, {
|
|
675
813
|
allowInsecureHttp: this.allowInsecureHttp,
|
|
814
|
+
insecure: this.insecure,
|
|
815
|
+
dispatcher: this.dispatcher,
|
|
676
816
|
});
|
|
677
817
|
}
|
|
678
818
|
catch (err) {
|
|
@@ -680,9 +820,12 @@ export class RemoteActionDockTarget {
|
|
|
680
820
|
}
|
|
681
821
|
}
|
|
682
822
|
async deleteConfig(packageId, key) {
|
|
823
|
+
this.assertNotClosed();
|
|
683
824
|
try {
|
|
684
825
|
const res = await deleteRemoteConfig(this.serverUrl, key, this.token, packageId || undefined, {
|
|
685
826
|
allowInsecureHttp: this.allowInsecureHttp,
|
|
827
|
+
insecure: this.insecure,
|
|
828
|
+
dispatcher: this.dispatcher,
|
|
686
829
|
});
|
|
687
830
|
return Boolean(res?.deleted ?? true);
|
|
688
831
|
}
|
|
@@ -691,9 +834,12 @@ export class RemoteActionDockTarget {
|
|
|
691
834
|
}
|
|
692
835
|
}
|
|
693
836
|
async listConfig(packageId) {
|
|
837
|
+
this.assertNotClosed();
|
|
694
838
|
try {
|
|
695
839
|
const res = await fetchRemoteConfig(this.serverUrl, this.token, packageId || undefined, {
|
|
696
840
|
allowInsecureHttp: this.allowInsecureHttp,
|
|
841
|
+
insecure: this.insecure,
|
|
842
|
+
dispatcher: this.dispatcher,
|
|
697
843
|
});
|
|
698
844
|
if (Array.isArray(res))
|
|
699
845
|
return res;
|
|
@@ -717,12 +863,15 @@ export class RemoteActionDockTarget {
|
|
|
717
863
|
}
|
|
718
864
|
}
|
|
719
865
|
async getState(packageId, actionId, key, options) {
|
|
866
|
+
this.assertNotClosed();
|
|
720
867
|
try {
|
|
721
868
|
const res = await getRemoteStateKey(this.serverUrl, key, this.token, {
|
|
722
869
|
package: packageId || undefined,
|
|
723
870
|
action: actionId || undefined,
|
|
724
871
|
namespace: options?.namespace,
|
|
725
872
|
allowInsecureHttp: this.allowInsecureHttp,
|
|
873
|
+
insecure: this.insecure,
|
|
874
|
+
dispatcher: this.dispatcher,
|
|
726
875
|
});
|
|
727
876
|
if (res === undefined)
|
|
728
877
|
return undefined;
|
|
@@ -739,6 +888,7 @@ export class RemoteActionDockTarget {
|
|
|
739
888
|
}
|
|
740
889
|
}
|
|
741
890
|
async setState(packageId, actionId, key, value, options) {
|
|
891
|
+
this.assertNotClosed();
|
|
742
892
|
try {
|
|
743
893
|
await setRemoteStateKey(this.serverUrl, key, value, this.token, {
|
|
744
894
|
package: packageId || undefined,
|
|
@@ -746,6 +896,8 @@ export class RemoteActionDockTarget {
|
|
|
746
896
|
namespace: options?.namespace,
|
|
747
897
|
ttl: options?.ttl,
|
|
748
898
|
allowInsecureHttp: this.allowInsecureHttp,
|
|
899
|
+
insecure: this.insecure,
|
|
900
|
+
dispatcher: this.dispatcher,
|
|
749
901
|
});
|
|
750
902
|
}
|
|
751
903
|
catch (err) {
|
|
@@ -753,12 +905,15 @@ export class RemoteActionDockTarget {
|
|
|
753
905
|
}
|
|
754
906
|
}
|
|
755
907
|
async deleteState(packageId, actionId, key, options) {
|
|
908
|
+
this.assertNotClosed();
|
|
756
909
|
try {
|
|
757
910
|
const res = await deleteRemoteStateKey(this.serverUrl, key, this.token, {
|
|
758
911
|
package: packageId || undefined,
|
|
759
912
|
action: actionId || undefined,
|
|
760
913
|
namespace: options?.namespace,
|
|
761
914
|
allowInsecureHttp: this.allowInsecureHttp,
|
|
915
|
+
insecure: this.insecure,
|
|
916
|
+
dispatcher: this.dispatcher,
|
|
762
917
|
});
|
|
763
918
|
return Boolean(res?.deleted ?? true);
|
|
764
919
|
}
|
|
@@ -770,6 +925,7 @@ export class RemoteActionDockTarget {
|
|
|
770
925
|
}
|
|
771
926
|
}
|
|
772
927
|
async listStateKeys(packageId, actionId, options) {
|
|
928
|
+
this.assertNotClosed();
|
|
773
929
|
try {
|
|
774
930
|
const res = await fetchRemoteStateList(this.serverUrl, this.token, {
|
|
775
931
|
package: packageId || undefined,
|
|
@@ -777,6 +933,8 @@ export class RemoteActionDockTarget {
|
|
|
777
933
|
namespace: options?.namespace,
|
|
778
934
|
prefix: options?.prefix,
|
|
779
935
|
allowInsecureHttp: this.allowInsecureHttp,
|
|
936
|
+
insecure: this.insecure,
|
|
937
|
+
dispatcher: this.dispatcher,
|
|
780
938
|
});
|
|
781
939
|
return res.keys || [];
|
|
782
940
|
}
|
|
@@ -785,6 +943,7 @@ export class RemoteActionDockTarget {
|
|
|
785
943
|
}
|
|
786
944
|
}
|
|
787
945
|
async clearState(packageId, actionId, options) {
|
|
946
|
+
this.assertNotClosed();
|
|
788
947
|
try {
|
|
789
948
|
const res = await clearRemoteState(this.serverUrl, this.token, {
|
|
790
949
|
package: packageId || undefined,
|
|
@@ -793,6 +952,8 @@ export class RemoteActionDockTarget {
|
|
|
793
952
|
prefix: options?.prefix,
|
|
794
953
|
all: options?.all,
|
|
795
954
|
allowInsecureHttp: this.allowInsecureHttp,
|
|
955
|
+
insecure: this.insecure,
|
|
956
|
+
dispatcher: this.dispatcher,
|
|
796
957
|
});
|
|
797
958
|
return res.clearedCount ?? 0;
|
|
798
959
|
}
|
|
@@ -801,10 +962,14 @@ export class RemoteActionDockTarget {
|
|
|
801
962
|
}
|
|
802
963
|
}
|
|
803
964
|
async listStateEntries(packageId, options) {
|
|
965
|
+
this.assertNotClosed();
|
|
804
966
|
throw new TargetError(TARGET_CAPABILITY_UNAVAILABLE, "TARGET_CAPABILITY_UNAVAILABLE: listStateEntries is not supported on remote target");
|
|
805
967
|
}
|
|
806
968
|
async close(_options) {
|
|
807
|
-
|
|
969
|
+
if (this.isClosed) {
|
|
970
|
+
return;
|
|
971
|
+
}
|
|
972
|
+
this.isClosed = true;
|
|
808
973
|
}
|
|
809
974
|
}
|
|
810
975
|
/**
|
package/dist/target/types.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export declare const ACTIONDOCK_PROTOCOL_VERSION = "2.0";
|
|
|
14
14
|
export declare const TARGET_PROTOCOL_UNSUPPORTED = "TARGET_PROTOCOL_UNSUPPORTED";
|
|
15
15
|
export declare const TARGET_CAPABILITY_UNAVAILABLE = "TARGET_CAPABILITY_UNAVAILABLE";
|
|
16
16
|
export declare const TARGET_RESULT_UNKNOWN = "TARGET_RESULT_UNKNOWN";
|
|
17
|
+
export declare const TARGET_CLOSED = "TARGET_CLOSED";
|
|
17
18
|
/**
|
|
18
19
|
* 结构化 Target 异常类。
|
|
19
20
|
*/
|
|
@@ -213,11 +214,19 @@ export interface RemoteTargetOptions {
|
|
|
213
214
|
token?: string;
|
|
214
215
|
/** 是否允许向非回环地址发送明文 HTTP 请求(默认 false) */
|
|
215
216
|
allowInsecureHttp?: boolean;
|
|
217
|
+
/** 是否跳过 TLS 证书合法性校验(用于局域网自签证书) */
|
|
218
|
+
insecure?: boolean;
|
|
219
|
+
/** 自定义底层 HTTP 调度器(平台中立) */
|
|
220
|
+
dispatcher?: unknown;
|
|
216
221
|
/** 请求超时时间(毫秒) */
|
|
217
222
|
timeoutMs?: number;
|
|
218
223
|
/** 轮询等待基准底线超时时间(毫秒,默认 60000ms) */
|
|
219
224
|
baseTimeoutMs?: number;
|
|
220
225
|
}
|
|
226
|
+
/**
|
|
227
|
+
* 远程 ActionDockTarget 选项别名契约。
|
|
228
|
+
*/
|
|
229
|
+
export type RemoteActionDockTargetOptions = RemoteTargetOptions;
|
|
221
230
|
/**
|
|
222
231
|
* 监督进程 IPC 目标初始化选项。
|
|
223
232
|
*/
|
package/dist/target/types.js
CHANGED
|
@@ -8,6 +8,7 @@ export const ACTIONDOCK_PROTOCOL_VERSION = "2.0";
|
|
|
8
8
|
export const TARGET_PROTOCOL_UNSUPPORTED = "TARGET_PROTOCOL_UNSUPPORTED";
|
|
9
9
|
export const TARGET_CAPABILITY_UNAVAILABLE = "TARGET_CAPABILITY_UNAVAILABLE";
|
|
10
10
|
export const TARGET_RESULT_UNKNOWN = "TARGET_RESULT_UNKNOWN";
|
|
11
|
+
export const TARGET_CLOSED = "TARGET_CLOSED";
|
|
11
12
|
/**
|
|
12
13
|
* 结构化 Target 异常类。
|
|
13
14
|
*/
|
package/dist/version.d.ts
CHANGED
package/dist/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@actiondock/core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0",
|
|
4
4
|
"description": "ActionDock Core Engine - Project loader, runtime execution, SQLite storage, standalone builder, and skill exporter",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"test": "node ../../scripts/run-tests.ts"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@actiondock/sdk": "^2.
|
|
32
|
+
"@actiondock/sdk": "^2.5.0",
|
|
33
33
|
"ajv": "^8.17.1",
|
|
34
34
|
"ajv-formats": "^3.0.1"
|
|
35
35
|
},
|