@hearsay-tools/squawk 0.18.0-dev.7956 → 0.18.0-dev.7960
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/ci-wait/controller.d.ts +42 -42
- package/dist/delegation/transport.d.ts +65 -65
- package/dist/server/bounded-read-cache.d.ts +10 -0
- package/dist/server/bounded-read-cache.js +54 -0
- package/dist/server/bounded-read-cache.js.map +1 -0
- package/dist/server/live-routes.d.ts +6 -6
- package/dist/server/models-routes.d.ts +13 -13
- package/dist/server/repo-branch-forge.js +38 -10
- package/dist/server/repo-branch-forge.js.map +1 -1
- package/dist/server/repo-branches.js +28 -17
- package/dist/server/repo-branches.js.map +1 -1
- package/dist/server/repo-read-cache.d.ts +22 -0
- package/dist/server/repo-read-cache.js +51 -0
- package/dist/server/repo-read-cache.js.map +1 -0
- package/dist/server/server.d.ts +1551 -1551
- package/dist/server/server.js +26 -23
- package/dist/server/server.js.map +1 -1
- package/dist/server/workspace-live-routes.d.ts +6 -6
- package/dist/server/worktree-size-cache.d.ts +3 -0
- package/dist/server/worktree-size-cache.js +8 -0
- package/dist/server/worktree-size-cache.js.map +1 -0
- package/package.json +4 -4
|
@@ -285,11 +285,12 @@ export declare function ciToolRoutes(capabilities: Map<string, Capability>): imp
|
|
|
285
285
|
"/api/v1/tools/ask": {
|
|
286
286
|
$post: {
|
|
287
287
|
output: {
|
|
288
|
-
|
|
288
|
+
ok: false;
|
|
289
|
+
code: 'unavailable';
|
|
289
290
|
message: string;
|
|
290
291
|
};
|
|
291
292
|
outputFormat: "json";
|
|
292
|
-
status:
|
|
293
|
+
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
293
294
|
input: {
|
|
294
295
|
json: {
|
|
295
296
|
questions: {
|
|
@@ -308,12 +309,11 @@ export declare function ciToolRoutes(capabilities: Map<string, Capability>): imp
|
|
|
308
309
|
};
|
|
309
310
|
} | {
|
|
310
311
|
output: {
|
|
311
|
-
|
|
312
|
-
code: 'unavailable';
|
|
312
|
+
code: 'capability_revoked';
|
|
313
313
|
message: string;
|
|
314
314
|
};
|
|
315
315
|
outputFormat: "json";
|
|
316
|
-
status:
|
|
316
|
+
status: 401;
|
|
317
317
|
input: {
|
|
318
318
|
json: {
|
|
319
319
|
questions: {
|
|
@@ -383,11 +383,12 @@ export declare function ciToolRoutes(capabilities: Map<string, Capability>): imp
|
|
|
383
383
|
"/api/v1/tools/cancel-wait": {
|
|
384
384
|
$post: {
|
|
385
385
|
output: {
|
|
386
|
-
|
|
386
|
+
cancelled: false;
|
|
387
|
+
code: 'unavailable';
|
|
387
388
|
message: string;
|
|
388
389
|
};
|
|
389
390
|
outputFormat: "json";
|
|
390
|
-
status:
|
|
391
|
+
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
391
392
|
input: {
|
|
392
393
|
json: {
|
|
393
394
|
wait_id: string;
|
|
@@ -395,12 +396,11 @@ export declare function ciToolRoutes(capabilities: Map<string, Capability>): imp
|
|
|
395
396
|
};
|
|
396
397
|
} | {
|
|
397
398
|
output: {
|
|
398
|
-
|
|
399
|
-
code: 'unavailable';
|
|
399
|
+
code: 'capability_revoked';
|
|
400
400
|
message: string;
|
|
401
401
|
};
|
|
402
402
|
outputFormat: "json";
|
|
403
|
-
status:
|
|
403
|
+
status: 401;
|
|
404
404
|
input: {
|
|
405
405
|
json: {
|
|
406
406
|
wait_id: string;
|
|
@@ -448,11 +448,12 @@ export declare function ciToolRoutes(capabilities: Map<string, Capability>): imp
|
|
|
448
448
|
"/api/v1/tools/done": {
|
|
449
449
|
$post: {
|
|
450
450
|
output: {
|
|
451
|
-
|
|
451
|
+
ok: false;
|
|
452
|
+
code: 'unavailable';
|
|
452
453
|
message: string;
|
|
453
454
|
};
|
|
454
455
|
outputFormat: "json";
|
|
455
|
-
status:
|
|
456
|
+
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
456
457
|
input: {
|
|
457
458
|
json: {
|
|
458
459
|
summary?: string | undefined;
|
|
@@ -460,12 +461,11 @@ export declare function ciToolRoutes(capabilities: Map<string, Capability>): imp
|
|
|
460
461
|
};
|
|
461
462
|
} | {
|
|
462
463
|
output: {
|
|
463
|
-
|
|
464
|
-
code: 'unavailable';
|
|
464
|
+
code: 'capability_revoked';
|
|
465
465
|
message: string;
|
|
466
466
|
};
|
|
467
467
|
outputFormat: "json";
|
|
468
|
-
status:
|
|
468
|
+
status: 401;
|
|
469
469
|
input: {
|
|
470
470
|
json: {
|
|
471
471
|
summary?: string | undefined;
|
|
@@ -548,11 +548,13 @@ export declare function ciToolRoutes(capabilities: Map<string, Capability>): imp
|
|
|
548
548
|
"/api/v1/tools/preview-stop": {
|
|
549
549
|
$post: {
|
|
550
550
|
output: {
|
|
551
|
-
|
|
551
|
+
ok: boolean;
|
|
552
|
+
code: "adopted" | "approval_required" | "headless" | "invalid_input" | "not_registered" | "port_held" | "port_in_use" | "preview_disabled" | "restarted" | "stopped" | "unavailable" | "worktree_missing";
|
|
552
553
|
message: string;
|
|
554
|
+
hint: string;
|
|
553
555
|
};
|
|
554
556
|
outputFormat: "json";
|
|
555
|
-
status:
|
|
557
|
+
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
556
558
|
input: {
|
|
557
559
|
json: {
|
|
558
560
|
port: number;
|
|
@@ -561,13 +563,11 @@ export declare function ciToolRoutes(capabilities: Map<string, Capability>): imp
|
|
|
561
563
|
};
|
|
562
564
|
} | {
|
|
563
565
|
output: {
|
|
564
|
-
|
|
565
|
-
code: "adopted" | "approval_required" | "headless" | "invalid_input" | "not_registered" | "port_held" | "port_in_use" | "preview_disabled" | "restarted" | "stopped" | "unavailable" | "worktree_missing";
|
|
566
|
+
code: 'capability_revoked';
|
|
566
567
|
message: string;
|
|
567
|
-
hint: string;
|
|
568
568
|
};
|
|
569
569
|
outputFormat: "json";
|
|
570
|
-
status:
|
|
570
|
+
status: 401;
|
|
571
571
|
input: {
|
|
572
572
|
json: {
|
|
573
573
|
port: number;
|
|
@@ -580,11 +580,13 @@ export declare function ciToolRoutes(capabilities: Map<string, Capability>): imp
|
|
|
580
580
|
"/api/v1/tools/preview-serve": {
|
|
581
581
|
$post: {
|
|
582
582
|
output: {
|
|
583
|
-
|
|
583
|
+
ok: boolean;
|
|
584
|
+
code: "cezar_port" | "cwd_outside_worktree" | "headless" | "invalid_input" | "port_held" | "preview_disabled" | "registered" | "replaced" | "too_many" | "unavailable" | "worktree_missing";
|
|
584
585
|
message: string;
|
|
586
|
+
hint: string;
|
|
585
587
|
};
|
|
586
588
|
outputFormat: "json";
|
|
587
|
-
status:
|
|
589
|
+
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
588
590
|
input: {
|
|
589
591
|
json: {
|
|
590
592
|
command: string;
|
|
@@ -596,13 +598,11 @@ export declare function ciToolRoutes(capabilities: Map<string, Capability>): imp
|
|
|
596
598
|
};
|
|
597
599
|
} | {
|
|
598
600
|
output: {
|
|
599
|
-
|
|
600
|
-
code: "cezar_port" | "cwd_outside_worktree" | "headless" | "invalid_input" | "port_held" | "preview_disabled" | "registered" | "replaced" | "too_many" | "unavailable" | "worktree_missing";
|
|
601
|
+
code: 'capability_revoked';
|
|
601
602
|
message: string;
|
|
602
|
-
hint: string;
|
|
603
603
|
};
|
|
604
604
|
outputFormat: "json";
|
|
605
|
-
status:
|
|
605
|
+
status: 401;
|
|
606
606
|
input: {
|
|
607
607
|
json: {
|
|
608
608
|
command: string;
|
|
@@ -618,11 +618,12 @@ export declare function ciToolRoutes(capabilities: Map<string, Capability>): imp
|
|
|
618
618
|
"/api/v1/tools/automation": {
|
|
619
619
|
$post: {
|
|
620
620
|
output: {
|
|
621
|
-
|
|
621
|
+
ok: false;
|
|
622
|
+
code: import('../contract/index.js').ScheduledTaskRefusalCode;
|
|
622
623
|
message: string;
|
|
623
624
|
};
|
|
624
625
|
outputFormat: "json";
|
|
625
|
-
status:
|
|
626
|
+
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
626
627
|
input: {
|
|
627
628
|
json: {
|
|
628
629
|
action: "create";
|
|
@@ -702,12 +703,11 @@ export declare function ciToolRoutes(capabilities: Map<string, Capability>): imp
|
|
|
702
703
|
};
|
|
703
704
|
} | {
|
|
704
705
|
output: {
|
|
705
|
-
|
|
706
|
-
code: import('../contract/index.js').ScheduledTaskRefusalCode;
|
|
706
|
+
code: 'capability_revoked';
|
|
707
707
|
message: string;
|
|
708
708
|
};
|
|
709
709
|
outputFormat: "json";
|
|
710
|
-
status:
|
|
710
|
+
status: 401;
|
|
711
711
|
input: {
|
|
712
712
|
json: {
|
|
713
713
|
action: "create";
|
|
@@ -963,11 +963,12 @@ export declare function ciToolRoutes(capabilities: Map<string, Capability>): imp
|
|
|
963
963
|
"/api/v1/tools/schedule-task": {
|
|
964
964
|
$post: {
|
|
965
965
|
output: {
|
|
966
|
-
|
|
966
|
+
ok: false;
|
|
967
|
+
code: import('../contract/index.js').ScheduledTaskRefusalCode;
|
|
967
968
|
message: string;
|
|
968
969
|
};
|
|
969
970
|
outputFormat: "json";
|
|
970
|
-
status:
|
|
971
|
+
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
971
972
|
input: {
|
|
972
973
|
json: {
|
|
973
974
|
at?: string | undefined;
|
|
@@ -984,12 +985,11 @@ export declare function ciToolRoutes(capabilities: Map<string, Capability>): imp
|
|
|
984
985
|
};
|
|
985
986
|
} | {
|
|
986
987
|
output: {
|
|
987
|
-
|
|
988
|
-
code: import('../contract/index.js').ScheduledTaskRefusalCode;
|
|
988
|
+
code: 'capability_revoked';
|
|
989
989
|
message: string;
|
|
990
990
|
};
|
|
991
991
|
outputFormat: "json";
|
|
992
|
-
status:
|
|
992
|
+
status: 401;
|
|
993
993
|
input: {
|
|
994
994
|
json: {
|
|
995
995
|
at?: string | undefined;
|
|
@@ -1044,11 +1044,12 @@ export declare function ciToolRoutes(capabilities: Map<string, Capability>): imp
|
|
|
1044
1044
|
"/api/v1/tools/scheduled-tasks": {
|
|
1045
1045
|
$post: {
|
|
1046
1046
|
output: {
|
|
1047
|
-
|
|
1047
|
+
ok: false;
|
|
1048
|
+
code: import('../contract/index.js').ScheduledTaskRefusalCode;
|
|
1048
1049
|
message: string;
|
|
1049
1050
|
};
|
|
1050
1051
|
outputFormat: "json";
|
|
1051
|
-
status:
|
|
1052
|
+
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
1052
1053
|
input: {
|
|
1053
1054
|
json: {
|
|
1054
1055
|
at?: string | undefined;
|
|
@@ -1081,12 +1082,11 @@ export declare function ciToolRoutes(capabilities: Map<string, Capability>): imp
|
|
|
1081
1082
|
};
|
|
1082
1083
|
} | {
|
|
1083
1084
|
output: {
|
|
1084
|
-
|
|
1085
|
-
code: import('../contract/index.js').ScheduledTaskRefusalCode;
|
|
1085
|
+
code: 'capability_revoked';
|
|
1086
1086
|
message: string;
|
|
1087
1087
|
};
|
|
1088
1088
|
outputFormat: "json";
|
|
1089
|
-
status:
|
|
1089
|
+
status: 401;
|
|
1090
1090
|
input: {
|
|
1091
1091
|
json: {
|
|
1092
1092
|
at?: string | undefined;
|
|
@@ -2,6 +2,18 @@ import type { DelegationRoutes } from './routes.ts';
|
|
|
2
2
|
export declare function createDelegationApp(routes: DelegationRoutes): import("hono/hono-base").HonoBase<import("hono/types").BlankEnv, import("hono/types").BlankSchema | import("hono/types").MergeSchemaPath<{
|
|
3
3
|
"/list": {
|
|
4
4
|
$get: {
|
|
5
|
+
output: {
|
|
6
|
+
error: string;
|
|
7
|
+
code?: "invalid_input" | undefined;
|
|
8
|
+
};
|
|
9
|
+
outputFormat: "json";
|
|
10
|
+
status: 400;
|
|
11
|
+
input: {
|
|
12
|
+
query: {
|
|
13
|
+
offset?: string | undefined;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
} | {
|
|
5
17
|
output: {
|
|
6
18
|
workers: {
|
|
7
19
|
workerId: string;
|
|
@@ -48,18 +60,6 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
|
|
|
48
60
|
offset?: string | undefined;
|
|
49
61
|
};
|
|
50
62
|
};
|
|
51
|
-
} | {
|
|
52
|
-
output: {
|
|
53
|
-
error: string;
|
|
54
|
-
code?: "invalid_input" | undefined;
|
|
55
|
-
};
|
|
56
|
-
outputFormat: "json";
|
|
57
|
-
status: 400;
|
|
58
|
-
input: {
|
|
59
|
-
query: {
|
|
60
|
-
offset?: string | undefined;
|
|
61
|
-
};
|
|
62
|
-
};
|
|
63
63
|
};
|
|
64
64
|
};
|
|
65
65
|
} & {
|
|
@@ -604,6 +604,18 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
|
|
|
604
604
|
} & {
|
|
605
605
|
"/:workerId": {
|
|
606
606
|
$get: {
|
|
607
|
+
output: {
|
|
608
|
+
error: string;
|
|
609
|
+
code?: "invalid_input" | undefined;
|
|
610
|
+
};
|
|
611
|
+
outputFormat: "json";
|
|
612
|
+
status: 400;
|
|
613
|
+
input: {
|
|
614
|
+
param: {
|
|
615
|
+
workerId: string;
|
|
616
|
+
};
|
|
617
|
+
};
|
|
618
|
+
} | {
|
|
607
619
|
output: {
|
|
608
620
|
workerId: string;
|
|
609
621
|
settled: boolean;
|
|
@@ -721,7 +733,11 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
|
|
|
721
733
|
workerId: string;
|
|
722
734
|
};
|
|
723
735
|
};
|
|
724
|
-
}
|
|
736
|
+
};
|
|
737
|
+
};
|
|
738
|
+
} & {
|
|
739
|
+
"/:workerId/collect": {
|
|
740
|
+
$post: {
|
|
725
741
|
output: {
|
|
726
742
|
error: string;
|
|
727
743
|
code?: "invalid_input" | undefined;
|
|
@@ -732,12 +748,10 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
|
|
|
732
748
|
param: {
|
|
733
749
|
workerId: string;
|
|
734
750
|
};
|
|
751
|
+
} & {
|
|
752
|
+
json: Record<string, never>;
|
|
735
753
|
};
|
|
736
|
-
}
|
|
737
|
-
};
|
|
738
|
-
} & {
|
|
739
|
-
"/:workerId/collect": {
|
|
740
|
-
$post: {
|
|
754
|
+
} | {
|
|
741
755
|
output: {
|
|
742
756
|
workerId: string;
|
|
743
757
|
parentRunId: string;
|
|
@@ -860,7 +874,11 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
|
|
|
860
874
|
} & {
|
|
861
875
|
json: Record<string, never>;
|
|
862
876
|
};
|
|
863
|
-
}
|
|
877
|
+
};
|
|
878
|
+
};
|
|
879
|
+
} & {
|
|
880
|
+
"/:workerId/steer": {
|
|
881
|
+
$post: {
|
|
864
882
|
output: {
|
|
865
883
|
error: string;
|
|
866
884
|
code?: "invalid_input" | undefined;
|
|
@@ -872,13 +890,11 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
|
|
|
872
890
|
workerId: string;
|
|
873
891
|
};
|
|
874
892
|
} & {
|
|
875
|
-
json:
|
|
893
|
+
json: {
|
|
894
|
+
text: string;
|
|
895
|
+
};
|
|
876
896
|
};
|
|
877
|
-
}
|
|
878
|
-
};
|
|
879
|
-
} & {
|
|
880
|
-
"/:workerId/steer": {
|
|
881
|
-
$post: {
|
|
897
|
+
} | {
|
|
882
898
|
output: {
|
|
883
899
|
workerId: string;
|
|
884
900
|
state: "delivered" | "queued";
|
|
@@ -894,7 +910,11 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
|
|
|
894
910
|
text: string;
|
|
895
911
|
};
|
|
896
912
|
};
|
|
897
|
-
}
|
|
913
|
+
};
|
|
914
|
+
};
|
|
915
|
+
} & {
|
|
916
|
+
"/:workerId/stop": {
|
|
917
|
+
$post: {
|
|
898
918
|
output: {
|
|
899
919
|
error: string;
|
|
900
920
|
code?: "invalid_input" | undefined;
|
|
@@ -906,15 +926,9 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
|
|
|
906
926
|
workerId: string;
|
|
907
927
|
};
|
|
908
928
|
} & {
|
|
909
|
-
json:
|
|
910
|
-
text: string;
|
|
911
|
-
};
|
|
929
|
+
json: Record<string, never>;
|
|
912
930
|
};
|
|
913
|
-
}
|
|
914
|
-
};
|
|
915
|
-
} & {
|
|
916
|
-
"/:workerId/stop": {
|
|
917
|
-
$post: {
|
|
931
|
+
} | {
|
|
918
932
|
output: {
|
|
919
933
|
workerId: string;
|
|
920
934
|
state: "stopping" | "terminated";
|
|
@@ -928,7 +942,11 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
|
|
|
928
942
|
} & {
|
|
929
943
|
json: Record<string, never>;
|
|
930
944
|
};
|
|
931
|
-
}
|
|
945
|
+
};
|
|
946
|
+
};
|
|
947
|
+
} & {
|
|
948
|
+
"/:workerId/destroy": {
|
|
949
|
+
$post: {
|
|
932
950
|
output: {
|
|
933
951
|
error: string;
|
|
934
952
|
code?: "invalid_input" | undefined;
|
|
@@ -940,13 +958,11 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
|
|
|
940
958
|
workerId: string;
|
|
941
959
|
};
|
|
942
960
|
} & {
|
|
943
|
-
json:
|
|
961
|
+
json: {
|
|
962
|
+
discardWork?: true | undefined;
|
|
963
|
+
};
|
|
944
964
|
};
|
|
945
|
-
}
|
|
946
|
-
};
|
|
947
|
-
} & {
|
|
948
|
-
"/:workerId/destroy": {
|
|
949
|
-
$post: {
|
|
965
|
+
} | {
|
|
950
966
|
output: {
|
|
951
967
|
workerId: string;
|
|
952
968
|
state: "complete" | "incomplete";
|
|
@@ -975,22 +991,6 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
|
|
|
975
991
|
discardWork?: true | undefined;
|
|
976
992
|
};
|
|
977
993
|
};
|
|
978
|
-
} | {
|
|
979
|
-
output: {
|
|
980
|
-
error: string;
|
|
981
|
-
code?: "invalid_input" | undefined;
|
|
982
|
-
};
|
|
983
|
-
outputFormat: "json";
|
|
984
|
-
status: 400;
|
|
985
|
-
input: {
|
|
986
|
-
param: {
|
|
987
|
-
workerId: string;
|
|
988
|
-
};
|
|
989
|
-
} & {
|
|
990
|
-
json: {
|
|
991
|
-
discardWork?: true | undefined;
|
|
992
|
-
};
|
|
993
|
-
};
|
|
994
994
|
} | {
|
|
995
995
|
output: {
|
|
996
996
|
workerId: string;
|
|
@@ -1026,13 +1026,11 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
|
|
|
1026
1026
|
"/:workerId/diff": {
|
|
1027
1027
|
$get: {
|
|
1028
1028
|
output: {
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
diff: string;
|
|
1032
|
-
truncated: boolean;
|
|
1029
|
+
error: string;
|
|
1030
|
+
code?: "invalid_input" | undefined;
|
|
1033
1031
|
};
|
|
1034
1032
|
outputFormat: "json";
|
|
1035
|
-
status:
|
|
1033
|
+
status: 400;
|
|
1036
1034
|
input: {
|
|
1037
1035
|
param: {
|
|
1038
1036
|
workerId: string;
|
|
@@ -1040,11 +1038,13 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
|
|
|
1040
1038
|
};
|
|
1041
1039
|
} | {
|
|
1042
1040
|
output: {
|
|
1043
|
-
|
|
1044
|
-
|
|
1041
|
+
workerId: string;
|
|
1042
|
+
baselineSha: string;
|
|
1043
|
+
diff: string;
|
|
1044
|
+
truncated: boolean;
|
|
1045
1045
|
};
|
|
1046
1046
|
outputFormat: "json";
|
|
1047
|
-
status:
|
|
1047
|
+
status: 200;
|
|
1048
1048
|
input: {
|
|
1049
1049
|
param: {
|
|
1050
1050
|
workerId: string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** A bounded process queue shared by cache misses. */
|
|
2
|
+
export declare function readQueue(limit: number): <T>(read: () => Promise<T>) => Promise<T>;
|
|
3
|
+
/** Entries include pending reads; invalidation detaches them without cancelling their callers. */
|
|
4
|
+
export declare function boundedReadCache<T>(ttl: number, max: number): {
|
|
5
|
+
read(key: string, load: () => Promise<T>): Promise<T>;
|
|
6
|
+
forget(key: string): void;
|
|
7
|
+
clear(): void;
|
|
8
|
+
};
|
|
9
|
+
/** Request-local memoization includes undefined results. */
|
|
10
|
+
export declare function memoizeRead<T>(read: (id: string) => T): (id: string) => T;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/** A bounded process queue shared by cache misses. */
|
|
2
|
+
export function readQueue(limit) {
|
|
3
|
+
let active = 0;
|
|
4
|
+
const waiting = [];
|
|
5
|
+
return async (read) => {
|
|
6
|
+
if (active >= limit)
|
|
7
|
+
await new Promise((resolve) => waiting.push(resolve));
|
|
8
|
+
else
|
|
9
|
+
active++;
|
|
10
|
+
try {
|
|
11
|
+
return await read();
|
|
12
|
+
}
|
|
13
|
+
finally {
|
|
14
|
+
const next = waiting.shift();
|
|
15
|
+
if (next)
|
|
16
|
+
next();
|
|
17
|
+
else
|
|
18
|
+
active--;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/** Entries include pending reads; invalidation detaches them without cancelling their callers. */
|
|
23
|
+
export function boundedReadCache(ttl, max) {
|
|
24
|
+
const entries = new Map();
|
|
25
|
+
return {
|
|
26
|
+
read(key, load) {
|
|
27
|
+
const hit = entries.get(key);
|
|
28
|
+
if (hit && hit.until > Date.now())
|
|
29
|
+
return hit.value;
|
|
30
|
+
const entry = { until: Infinity, value: Promise.resolve().then(load) };
|
|
31
|
+
entries.delete(key);
|
|
32
|
+
entries.set(key, entry);
|
|
33
|
+
while (entries.size > max)
|
|
34
|
+
entries.delete(entries.keys().next().value);
|
|
35
|
+
void entry.value.then(() => { entry.until = Date.now() + ttl; }, () => {
|
|
36
|
+
if (entries.get(key) === entry)
|
|
37
|
+
entries.delete(key);
|
|
38
|
+
});
|
|
39
|
+
return entry.value;
|
|
40
|
+
},
|
|
41
|
+
forget(key) { entries.delete(key); },
|
|
42
|
+
clear() { entries.clear(); },
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/** Request-local memoization includes undefined results. */
|
|
46
|
+
export function memoizeRead(read) {
|
|
47
|
+
const values = new Map();
|
|
48
|
+
return (id) => {
|
|
49
|
+
if (!values.has(id))
|
|
50
|
+
values.set(id, read(id));
|
|
51
|
+
return values.get(id);
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=bounded-read-cache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bounded-read-cache.js","sourceRoot":"","sources":["../../src/server/bounded-read-cache.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,MAAM,UAAU,SAAS,CAAC,KAAa;IACrC,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,MAAM,OAAO,GAAsB,EAAE,CAAC;IACtC,OAAO,KAAK,EAAK,IAAsB,EAAc,EAAE;QACrD,IAAI,MAAM,IAAI,KAAK;YAAE,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;;YAC5E,MAAM,EAAE,CAAC;QACd,IAAI,CAAC;YAAC,OAAO,MAAM,IAAI,EAAE,CAAC;QAAC,CAAC;gBACpB,CAAC;YACP,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;YAC7B,IAAI,IAAI;gBAAE,IAAI,EAAE,CAAC;;gBACZ,MAAM,EAAE,CAAC;QAChB,CAAC;IACH,CAAC,CAAC;AACJ,CAAC;AAED,kGAAkG;AAClG,MAAM,UAAU,gBAAgB,CAAI,GAAW,EAAE,GAAW;IAC1D,MAAM,OAAO,GAAG,IAAI,GAAG,EAAgD,CAAC;IACxE,OAAO;QACL,IAAI,CAAC,GAAW,EAAE,IAAsB;YACtC,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YAC7B,IAAI,GAAG,IAAI,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE;gBAAE,OAAO,GAAG,CAAC,KAAK,CAAC;YACpD,MAAM,KAAK,GAAG,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YACvE,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YACpB,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;YACxB,OAAO,OAAO,CAAC,IAAI,GAAG,GAAG;gBAAE,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,KAAM,CAAC,CAAC;YACxE,KAAK,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE;gBACpE,IAAI,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,KAAK;oBAAE,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YACtD,CAAC,CAAC,CAAC;YACH,OAAO,KAAK,CAAC,KAAK,CAAC;QACrB,CAAC;QACD,MAAM,CAAC,GAAW,IAAI,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAC5C,KAAK,KAAK,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;KAC7B,CAAC;AACJ,CAAC;AAED,4DAA4D;AAC5D,MAAM,UAAU,WAAW,CAAI,IAAuB;IACpD,MAAM,MAAM,GAAG,IAAI,GAAG,EAAa,CAAC;IACpC,OAAO,CAAC,EAAE,EAAE,EAAE;QACZ,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;YAAE,MAAM,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;QAC9C,OAAO,MAAM,CAAC,GAAG,CAAC,EAAE,CAAE,CAAC;IACzB,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -16,12 +16,6 @@ export declare function createLiveRoutes({ resolveProject, serverGeneration, res
|
|
|
16
16
|
output: {
|
|
17
17
|
generation: string;
|
|
18
18
|
results: ({
|
|
19
|
-
projectId: string;
|
|
20
|
-
runId: string;
|
|
21
|
-
type: "error" | "reset";
|
|
22
|
-
status: 400 | 404 | 409 | 413 | 503;
|
|
23
|
-
error: string;
|
|
24
|
-
} | {
|
|
25
19
|
projectId: string;
|
|
26
20
|
runId: string;
|
|
27
21
|
type: "batch";
|
|
@@ -35,6 +29,12 @@ export declare function createLiveRoutes({ resolveProject, serverGeneration, res
|
|
|
35
29
|
cursor: string;
|
|
36
30
|
afterSeq: number;
|
|
37
31
|
hasMore: boolean;
|
|
32
|
+
} | {
|
|
33
|
+
projectId: string;
|
|
34
|
+
runId: string;
|
|
35
|
+
type: "error" | "reset";
|
|
36
|
+
status: 400 | 404 | 409 | 413 | 503;
|
|
37
|
+
error: string;
|
|
38
38
|
})[];
|
|
39
39
|
};
|
|
40
40
|
outputFormat: "json";
|
|
@@ -30,10 +30,19 @@ export declare function createModelsRoutes(options: {
|
|
|
30
30
|
};
|
|
31
31
|
} | {
|
|
32
32
|
output: {
|
|
33
|
-
|
|
33
|
+
runner: string;
|
|
34
|
+
models: {
|
|
35
|
+
id: string;
|
|
36
|
+
label: string;
|
|
37
|
+
description: string;
|
|
38
|
+
effortLevels?: import('../contract/index.js').EffortLevel[];
|
|
39
|
+
}[];
|
|
40
|
+
source: import("../core/runner-model-catalog.ts").ModelCatalogSource;
|
|
41
|
+
stale: boolean;
|
|
42
|
+
reason?: string;
|
|
34
43
|
};
|
|
35
44
|
outputFormat: "json";
|
|
36
|
-
status:
|
|
45
|
+
status: import("hono/utils/http-status").ContentfulStatusCode;
|
|
37
46
|
input: {
|
|
38
47
|
query: {
|
|
39
48
|
runner: string | string[];
|
|
@@ -54,19 +63,10 @@ export declare function createModelsRoutes(options: {
|
|
|
54
63
|
};
|
|
55
64
|
} | {
|
|
56
65
|
output: {
|
|
57
|
-
|
|
58
|
-
models: {
|
|
59
|
-
id: string;
|
|
60
|
-
label: string;
|
|
61
|
-
description: string;
|
|
62
|
-
effortLevels?: import('../contract/index.js').EffortLevel[];
|
|
63
|
-
}[];
|
|
64
|
-
source: import("../core/runner-model-catalog.ts").ModelCatalogSource;
|
|
65
|
-
stale: boolean;
|
|
66
|
-
reason?: string;
|
|
66
|
+
error: string;
|
|
67
67
|
};
|
|
68
68
|
outputFormat: "json";
|
|
69
|
-
status:
|
|
69
|
+
status: 400;
|
|
70
70
|
input: {
|
|
71
71
|
query: {
|
|
72
72
|
runner: string | string[];
|