@abelxiaoxing/cadence 2.1.8 → 2.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/README.zh-CN.md +3 -1
- package/docs/remote-access.md +13 -3
- package/docs/service-management.md +1 -1
- package/package.json +1 -1
- package/src/model-preview.mjs +1 -0
- package/src/native-build.ts +1 -1
- package/src/service-cli.mjs +23 -1
- package/src/service-host.mjs +793 -80
- package/src/worker-public.mjs +1 -0
- package/web/dist/assets/cadence.js +2 -2
- package/web/dist/manifest.json +5 -5
package/src/service-host.mjs
CHANGED
|
@@ -325,6 +325,7 @@ var LIMITS = Object.freeze({
|
|
|
325
325
|
stopWaitMs: 60000,
|
|
326
326
|
authValidityMarginMs: 120000,
|
|
327
327
|
browserLifetimeMs: 12 * 60 * 60 * 1000,
|
|
328
|
+
cookieLifetimeMs: 365 * 24 * 60 * 60 * 1000,
|
|
328
329
|
terminateGraceMs: 1000,
|
|
329
330
|
unconfirmedStopMs: 3000,
|
|
330
331
|
graphBytes: 512 * 1024,
|
|
@@ -10451,6 +10452,23 @@ function decodeCookieToken(raw) {
|
|
|
10451
10452
|
return raw;
|
|
10452
10453
|
}
|
|
10453
10454
|
}
|
|
10455
|
+
function sanitizeNextPath(raw) {
|
|
10456
|
+
const fallback = "/app";
|
|
10457
|
+
if (typeof raw !== "string")
|
|
10458
|
+
return fallback;
|
|
10459
|
+
const value = raw.trim();
|
|
10460
|
+
if (!value.startsWith("/") || value.startsWith("//") || value.includes("\\") || /[\x00-\x1f\x7f]/u.test(value))
|
|
10461
|
+
return fallback;
|
|
10462
|
+
try {
|
|
10463
|
+
const url = new URL(value, "http://cadence.invalid");
|
|
10464
|
+
url.searchParams.delete("token");
|
|
10465
|
+
url.searchParams.delete("auth_error");
|
|
10466
|
+
const path = `${url.pathname}${url.search}${url.hash}`;
|
|
10467
|
+
return path.startsWith("/") && !path.startsWith("//") ? path : fallback;
|
|
10468
|
+
} catch {
|
|
10469
|
+
return fallback;
|
|
10470
|
+
}
|
|
10471
|
+
}
|
|
10454
10472
|
function cookieTokens(header, name) {
|
|
10455
10473
|
if (!header)
|
|
10456
10474
|
return [];
|
|
@@ -10758,7 +10776,28 @@ class HttpAuthentication {
|
|
|
10758
10776
|
throw new ContractError("forbidden");
|
|
10759
10777
|
if (!this.material.matches(value))
|
|
10760
10778
|
throw new ContractError("unauthenticated");
|
|
10761
|
-
return buildTokenCookie(this.cookieName, encodeURIComponent(value), LIMITS.
|
|
10779
|
+
return buildTokenCookie(this.cookieName, encodeURIComponent(value), LIMITS.cookieLifetimeMs / 1000, boundary.secure);
|
|
10780
|
+
}
|
|
10781
|
+
login(value, boundary) {
|
|
10782
|
+
this.material.assertCurrent();
|
|
10783
|
+
const origin = boundary.headers.get("origin");
|
|
10784
|
+
if (origin === undefined || origin !== boundary.origin)
|
|
10785
|
+
throw new ContractError("forbidden");
|
|
10786
|
+
if (!this.material.matches(value))
|
|
10787
|
+
throw new ContractError("unauthenticated");
|
|
10788
|
+
return buildTokenCookie(this.cookieName, encodeURIComponent(value), LIMITS.cookieLifetimeMs / 1000, boundary.secure);
|
|
10789
|
+
}
|
|
10790
|
+
clearCookie(secure) {
|
|
10791
|
+
return buildTokenCookie(this.cookieName, "", 0, secure);
|
|
10792
|
+
}
|
|
10793
|
+
carriesCookie(header) {
|
|
10794
|
+
if (!header)
|
|
10795
|
+
return false;
|
|
10796
|
+
for (const part of header.split(";")) {
|
|
10797
|
+
if (part.trim().split("=")[0] === this.cookieName)
|
|
10798
|
+
return true;
|
|
10799
|
+
}
|
|
10800
|
+
return false;
|
|
10762
10801
|
}
|
|
10763
10802
|
authenticate(boundary, attachmentId, mutation2 = false, websocket = false) {
|
|
10764
10803
|
this.material.assertCurrent();
|
|
@@ -10794,6 +10833,545 @@ class HttpAuthentication {
|
|
|
10794
10833
|
}
|
|
10795
10834
|
}
|
|
10796
10835
|
|
|
10836
|
+
// src/service/auth-form.ts
|
|
10837
|
+
async function readLoginForm(req, signal) {
|
|
10838
|
+
if (req.headers["content-type"] !== "application/x-www-form-urlencoded" || req.headers["content-encoding"] !== undefined || req.headers["transfer-encoding"] !== undefined)
|
|
10839
|
+
throw new ContractError("invalid");
|
|
10840
|
+
const length = req.headers["content-length"];
|
|
10841
|
+
if (length !== undefined && (!/^(0|[1-9][0-9]*)$/.test(length) || Number(length) > LIMITS.controlBytes))
|
|
10842
|
+
throw new ContractError("oversize");
|
|
10843
|
+
const chunks = [];
|
|
10844
|
+
let bytes = 0;
|
|
10845
|
+
for await (const chunk of req.iterator({ destroyOnReturn: false })) {
|
|
10846
|
+
if (signal?.aborted)
|
|
10847
|
+
throw new ContractError("unavailable");
|
|
10848
|
+
bytes += chunk.length;
|
|
10849
|
+
if (bytes > LIMITS.controlBytes)
|
|
10850
|
+
throw new ContractError("oversize");
|
|
10851
|
+
chunks.push(chunk);
|
|
10852
|
+
}
|
|
10853
|
+
let form;
|
|
10854
|
+
try {
|
|
10855
|
+
form = new URLSearchParams(new TextDecoder("utf-8", { fatal: true }).decode(Buffer.concat(chunks)));
|
|
10856
|
+
} catch {
|
|
10857
|
+
throw new ContractError("invalid");
|
|
10858
|
+
}
|
|
10859
|
+
if (form.getAll("password").length !== 1 || form.getAll("next").length > 1 || [...form.keys()].some((key) => key !== "password" && key !== "next"))
|
|
10860
|
+
throw new ContractError("invalid");
|
|
10861
|
+
return {
|
|
10862
|
+
password: form.get("password") ?? "",
|
|
10863
|
+
next: sanitizeNextPath(form.get("next"))
|
|
10864
|
+
};
|
|
10865
|
+
}
|
|
10866
|
+
function loginRetryPath(next) {
|
|
10867
|
+
const target = sanitizeNextPath(next);
|
|
10868
|
+
return target === "/app" ? "/?auth_error=1" : `/?${new URLSearchParams({ auth_error: "1", next: target })}`;
|
|
10869
|
+
}
|
|
10870
|
+
function loginNextPath(url) {
|
|
10871
|
+
return sanitizeNextPath(url.pathname === "/" && url.searchParams.has("auth_error") ? url.searchParams.get("next") : `${url.pathname}${url.search}${url.hash}`);
|
|
10872
|
+
}
|
|
10873
|
+
|
|
10874
|
+
// src/service/auth-page.ts
|
|
10875
|
+
import { createHash as createHash9 } from "node:crypto";
|
|
10876
|
+
var styles = `
|
|
10877
|
+
:root {
|
|
10878
|
+
color-scheme: dark;
|
|
10879
|
+
font-family:
|
|
10880
|
+
Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
|
|
10881
|
+
color: #edf4f1;
|
|
10882
|
+
background: #0a100f;
|
|
10883
|
+
font-synthesis: none;
|
|
10884
|
+
}
|
|
10885
|
+
* {
|
|
10886
|
+
box-sizing: border-box;
|
|
10887
|
+
}
|
|
10888
|
+
body {
|
|
10889
|
+
margin: 0;
|
|
10890
|
+
min-height: 100vh;
|
|
10891
|
+
min-height: 100svh;
|
|
10892
|
+
display: grid;
|
|
10893
|
+
place-items: center;
|
|
10894
|
+
padding: 40px 28px;
|
|
10895
|
+
background:
|
|
10896
|
+
radial-gradient(ellipse at 12% 5%, #183a302e, transparent 55%),
|
|
10897
|
+
radial-gradient(ellipse at 90% 95%, #253b492e, transparent 50%), #0a100f;
|
|
10898
|
+
}
|
|
10899
|
+
body::before {
|
|
10900
|
+
content: "";
|
|
10901
|
+
position: fixed;
|
|
10902
|
+
inset: 0;
|
|
10903
|
+
pointer-events: none;
|
|
10904
|
+
background-image:
|
|
10905
|
+
linear-gradient(#9bc6b605 1px, transparent 1px),
|
|
10906
|
+
linear-gradient(90deg, #9bc6b605 1px, transparent 1px);
|
|
10907
|
+
background-size: 64px 64px;
|
|
10908
|
+
}
|
|
10909
|
+
main {
|
|
10910
|
+
position: relative;
|
|
10911
|
+
display: grid;
|
|
10912
|
+
grid-template-columns: 1.1fr 1fr;
|
|
10913
|
+
width: min(1080px, 100%);
|
|
10914
|
+
min-height: 650px;
|
|
10915
|
+
border: 1px solid #b2d6c51c;
|
|
10916
|
+
border-radius: 28px;
|
|
10917
|
+
overflow: hidden;
|
|
10918
|
+
background: #101916;
|
|
10919
|
+
box-shadow: 0 40px 100px #0005;
|
|
10920
|
+
}
|
|
10921
|
+
.story {
|
|
10922
|
+
position: relative;
|
|
10923
|
+
isolation: isolate;
|
|
10924
|
+
overflow: hidden;
|
|
10925
|
+
padding: 42px 48px;
|
|
10926
|
+
display: flex;
|
|
10927
|
+
flex-direction: column;
|
|
10928
|
+
background:
|
|
10929
|
+
radial-gradient(ellipse at 25% 80%, #2e6f4d40, transparent 65%),
|
|
10930
|
+
linear-gradient(145deg, #172922, #101c19);
|
|
10931
|
+
}
|
|
10932
|
+
.brand {
|
|
10933
|
+
display: flex;
|
|
10934
|
+
align-items: center;
|
|
10935
|
+
gap: 11px;
|
|
10936
|
+
font-size: 20px;
|
|
10937
|
+
font-weight: 600;
|
|
10938
|
+
letter-spacing: -0.7px;
|
|
10939
|
+
}
|
|
10940
|
+
.brand svg {
|
|
10941
|
+
width: 34px;
|
|
10942
|
+
height: 34px;
|
|
10943
|
+
color: #b8f3ce;
|
|
10944
|
+
}
|
|
10945
|
+
.intro {
|
|
10946
|
+
position: relative;
|
|
10947
|
+
z-index: 1;
|
|
10948
|
+
margin-top: 76px;
|
|
10949
|
+
}
|
|
10950
|
+
.eyebrow {
|
|
10951
|
+
font-size: 10px;
|
|
10952
|
+
font-weight: 600;
|
|
10953
|
+
letter-spacing: 2.3px;
|
|
10954
|
+
text-transform: uppercase;
|
|
10955
|
+
color: #a4bdb1;
|
|
10956
|
+
margin: 0 0 19px;
|
|
10957
|
+
}
|
|
10958
|
+
.headline {
|
|
10959
|
+
font-size: clamp(42px, 4.4vw, 58px);
|
|
10960
|
+
font-weight: 450;
|
|
10961
|
+
line-height: 1.08;
|
|
10962
|
+
letter-spacing: -2.7px;
|
|
10963
|
+
margin: 0;
|
|
10964
|
+
}
|
|
10965
|
+
.headline em {
|
|
10966
|
+
font-style: normal;
|
|
10967
|
+
color: #bbf4cf;
|
|
10968
|
+
}
|
|
10969
|
+
.lede {
|
|
10970
|
+
max-width: 310px;
|
|
10971
|
+
margin: 24px 0 0;
|
|
10972
|
+
color: #a8beb2;
|
|
10973
|
+
font-size: 14px;
|
|
10974
|
+
line-height: 1.75;
|
|
10975
|
+
}
|
|
10976
|
+
.orbit {
|
|
10977
|
+
position: absolute;
|
|
10978
|
+
z-index: -1;
|
|
10979
|
+
width: 430px;
|
|
10980
|
+
height: 430px;
|
|
10981
|
+
right: -180px;
|
|
10982
|
+
bottom: -175px;
|
|
10983
|
+
border: 1px solid #b8f3ce30;
|
|
10984
|
+
border-radius: 50%;
|
|
10985
|
+
box-shadow:
|
|
10986
|
+
0 0 80px #8affac09,
|
|
10987
|
+
inset 0 0 80px #8affac09;
|
|
10988
|
+
}
|
|
10989
|
+
.orbit::before,
|
|
10990
|
+
.orbit::after {
|
|
10991
|
+
content: "";
|
|
10992
|
+
position: absolute;
|
|
10993
|
+
border-radius: 50%;
|
|
10994
|
+
border: 1px solid #b8f3ce1a;
|
|
10995
|
+
inset: 44px;
|
|
10996
|
+
}
|
|
10997
|
+
.orbit::after {
|
|
10998
|
+
inset: -48px;
|
|
10999
|
+
border-style: dashed;
|
|
11000
|
+
border-color: #b8f3ce17;
|
|
11001
|
+
}
|
|
11002
|
+
.satellite {
|
|
11003
|
+
position: absolute;
|
|
11004
|
+
inset: 0;
|
|
11005
|
+
border-radius: 50%;
|
|
11006
|
+
animation: orbit 36s linear infinite;
|
|
11007
|
+
}
|
|
11008
|
+
.satellite::before {
|
|
11009
|
+
content: "";
|
|
11010
|
+
position: absolute;
|
|
11011
|
+
top: 60px;
|
|
11012
|
+
left: 60px;
|
|
11013
|
+
width: 8px;
|
|
11014
|
+
height: 8px;
|
|
11015
|
+
border-radius: 50%;
|
|
11016
|
+
background: #c2f6d3;
|
|
11017
|
+
box-shadow: 0 0 24px #b6ffcd88;
|
|
11018
|
+
}
|
|
11019
|
+
.rhythm {
|
|
11020
|
+
display: flex;
|
|
11021
|
+
align-items: center;
|
|
11022
|
+
gap: 14px;
|
|
11023
|
+
margin-top: auto;
|
|
11024
|
+
padding-top: 72px;
|
|
11025
|
+
font-size: 11px;
|
|
11026
|
+
color: #b0c4b8;
|
|
11027
|
+
letter-spacing: 0.3px;
|
|
11028
|
+
}
|
|
11029
|
+
.rhythm span {
|
|
11030
|
+
color: #638273;
|
|
11031
|
+
}
|
|
11032
|
+
.entry {
|
|
11033
|
+
display: flex;
|
|
11034
|
+
flex-direction: column;
|
|
11035
|
+
justify-content: center;
|
|
11036
|
+
padding: 64px 56px;
|
|
11037
|
+
background: linear-gradient(150deg, #16201b66, transparent 65%);
|
|
11038
|
+
}
|
|
11039
|
+
.access {
|
|
11040
|
+
display: inline-flex;
|
|
11041
|
+
align-items: center;
|
|
11042
|
+
gap: 7px;
|
|
11043
|
+
width: fit-content;
|
|
11044
|
+
border: 1px solid #d6f3e51a;
|
|
11045
|
+
border-radius: 999px;
|
|
11046
|
+
padding: 7px 10px;
|
|
11047
|
+
font-size: 10px;
|
|
11048
|
+
letter-spacing: 1.4px;
|
|
11049
|
+
color: #bed2c5;
|
|
11050
|
+
text-transform: uppercase;
|
|
11051
|
+
margin-bottom: 30px;
|
|
11052
|
+
}
|
|
11053
|
+
.access svg {
|
|
11054
|
+
width: 12px;
|
|
11055
|
+
height: 12px;
|
|
11056
|
+
color: #b8edc7;
|
|
11057
|
+
}
|
|
11058
|
+
h1 {
|
|
11059
|
+
font-size: 32px;
|
|
11060
|
+
line-height: 1.2;
|
|
11061
|
+
font-weight: 500;
|
|
11062
|
+
letter-spacing: -1.2px;
|
|
11063
|
+
margin: 0 0 12px;
|
|
11064
|
+
}
|
|
11065
|
+
.description {
|
|
11066
|
+
font-size: 14px;
|
|
11067
|
+
color: #a5b5ab;
|
|
11068
|
+
line-height: 1.65;
|
|
11069
|
+
margin: 0 0 32px;
|
|
11070
|
+
}
|
|
11071
|
+
label {
|
|
11072
|
+
display: block;
|
|
11073
|
+
font-size: 12px;
|
|
11074
|
+
font-weight: 500;
|
|
11075
|
+
color: #d1e0d6;
|
|
11076
|
+
margin-bottom: 10px;
|
|
11077
|
+
}
|
|
11078
|
+
.field {
|
|
11079
|
+
position: relative;
|
|
11080
|
+
}
|
|
11081
|
+
.field svg {
|
|
11082
|
+
position: absolute;
|
|
11083
|
+
left: 16px;
|
|
11084
|
+
top: 18px;
|
|
11085
|
+
width: 18px;
|
|
11086
|
+
height: 18px;
|
|
11087
|
+
color: #849e8e;
|
|
11088
|
+
pointer-events: none;
|
|
11089
|
+
}
|
|
11090
|
+
input[type="password"] {
|
|
11091
|
+
display: block;
|
|
11092
|
+
width: 100%;
|
|
11093
|
+
height: 54px;
|
|
11094
|
+
border: 1px solid #c2e7cf26;
|
|
11095
|
+
border-radius: 10px;
|
|
11096
|
+
background: #0b130f;
|
|
11097
|
+
color: #edf4f1;
|
|
11098
|
+
padding: 0 16px 0 46px;
|
|
11099
|
+
font:
|
|
11100
|
+
16px ui-monospace,
|
|
11101
|
+
SFMono-Regular,
|
|
11102
|
+
Consolas,
|
|
11103
|
+
monospace;
|
|
11104
|
+
letter-spacing: 1px;
|
|
11105
|
+
transition:
|
|
11106
|
+
border-color 0.2s,
|
|
11107
|
+
box-shadow 0.2s;
|
|
11108
|
+
}
|
|
11109
|
+
input::placeholder {
|
|
11110
|
+
font:
|
|
11111
|
+
13px ui-sans-serif,
|
|
11112
|
+
system-ui,
|
|
11113
|
+
sans-serif;
|
|
11114
|
+
letter-spacing: 0;
|
|
11115
|
+
color: #7f9588;
|
|
11116
|
+
}
|
|
11117
|
+
input:hover {
|
|
11118
|
+
border-color: #a9d9b950;
|
|
11119
|
+
}
|
|
11120
|
+
input:focus-visible {
|
|
11121
|
+
outline: 2px solid #b8f3ce;
|
|
11122
|
+
outline-offset: 3px;
|
|
11123
|
+
border-color: #b8f3ce;
|
|
11124
|
+
}
|
|
11125
|
+
input[aria-invalid="true"] {
|
|
11126
|
+
border-color: #e5aa87;
|
|
11127
|
+
}
|
|
11128
|
+
.hint {
|
|
11129
|
+
margin: 10px 0 24px;
|
|
11130
|
+
font-size: 12px;
|
|
11131
|
+
line-height: 1.6;
|
|
11132
|
+
color: #92a99a;
|
|
11133
|
+
}
|
|
11134
|
+
button {
|
|
11135
|
+
width: 100%;
|
|
11136
|
+
min-height: 52px;
|
|
11137
|
+
display: flex;
|
|
11138
|
+
align-items: center;
|
|
11139
|
+
justify-content: center;
|
|
11140
|
+
gap: 12px;
|
|
11141
|
+
border: 1px solid #d8ffe0;
|
|
11142
|
+
border-radius: 10px;
|
|
11143
|
+
background: #c5f5d4;
|
|
11144
|
+
color: #14271c;
|
|
11145
|
+
font:
|
|
11146
|
+
600 13px ui-sans-serif,
|
|
11147
|
+
system-ui,
|
|
11148
|
+
sans-serif;
|
|
11149
|
+
cursor: pointer;
|
|
11150
|
+
box-shadow: 0 4px 24px #9cffbb0a;
|
|
11151
|
+
transition:
|
|
11152
|
+
background 0.2s,
|
|
11153
|
+
transform 0.2s,
|
|
11154
|
+
box-shadow 0.2s;
|
|
11155
|
+
}
|
|
11156
|
+
button svg {
|
|
11157
|
+
width: 17px;
|
|
11158
|
+
height: 17px;
|
|
11159
|
+
transition: transform 0.2s;
|
|
11160
|
+
}
|
|
11161
|
+
button:hover {
|
|
11162
|
+
background: #d8ffe3;
|
|
11163
|
+
box-shadow: 0 4px 28px #9cffbb1c;
|
|
11164
|
+
transform: translateY(-1px);
|
|
11165
|
+
}
|
|
11166
|
+
button:hover svg {
|
|
11167
|
+
transform: translateX(3px);
|
|
11168
|
+
}
|
|
11169
|
+
button:active {
|
|
11170
|
+
transform: translateY(0);
|
|
11171
|
+
}
|
|
11172
|
+
button:focus-visible {
|
|
11173
|
+
outline: 2px solid #c5f5d4;
|
|
11174
|
+
outline-offset: 4px;
|
|
11175
|
+
}
|
|
11176
|
+
.remember {
|
|
11177
|
+
margin: 22px auto 0;
|
|
11178
|
+
max-width: 270px;
|
|
11179
|
+
text-align: center;
|
|
11180
|
+
color: #91a799;
|
|
11181
|
+
font-size: 11px;
|
|
11182
|
+
line-height: 1.8;
|
|
11183
|
+
}
|
|
11184
|
+
.notice {
|
|
11185
|
+
font-size: 12px;
|
|
11186
|
+
color: #f4c6a9;
|
|
11187
|
+
background: #a34a2019;
|
|
11188
|
+
border: 1px solid #dca47c40;
|
|
11189
|
+
border-radius: 10px;
|
|
11190
|
+
padding: 12px 14px;
|
|
11191
|
+
margin: 0 0 20px;
|
|
11192
|
+
line-height: 1.65;
|
|
11193
|
+
}
|
|
11194
|
+
footer {
|
|
11195
|
+
position: relative;
|
|
11196
|
+
grid-column: 1 / -1;
|
|
11197
|
+
display: flex;
|
|
11198
|
+
justify-content: space-between;
|
|
11199
|
+
gap: 16px;
|
|
11200
|
+
width: min(1080px, 100%);
|
|
11201
|
+
padding: 20px 8px 0;
|
|
11202
|
+
color: #829b8b;
|
|
11203
|
+
font-size: 10px;
|
|
11204
|
+
letter-spacing: 0.3px;
|
|
11205
|
+
}
|
|
11206
|
+
.shell {
|
|
11207
|
+
width: 100%;
|
|
11208
|
+
display: grid;
|
|
11209
|
+
justify-items: center;
|
|
11210
|
+
}
|
|
11211
|
+
@keyframes orbit {
|
|
11212
|
+
to {
|
|
11213
|
+
transform: rotate(360deg);
|
|
11214
|
+
}
|
|
11215
|
+
}
|
|
11216
|
+
@media (min-width: 1600px) {
|
|
11217
|
+
main {
|
|
11218
|
+
min-height: 700px;
|
|
11219
|
+
}
|
|
11220
|
+
.intro {
|
|
11221
|
+
margin-top: 100px;
|
|
11222
|
+
}
|
|
11223
|
+
}
|
|
11224
|
+
@media (max-width: 800px) {
|
|
11225
|
+
body {
|
|
11226
|
+
padding: 24px 18px;
|
|
11227
|
+
}
|
|
11228
|
+
main {
|
|
11229
|
+
grid-template-columns: 1fr;
|
|
11230
|
+
max-width: 480px;
|
|
11231
|
+
min-height: 0;
|
|
11232
|
+
border-radius: 22px;
|
|
11233
|
+
}
|
|
11234
|
+
.story {
|
|
11235
|
+
padding: 28px 30px 30px;
|
|
11236
|
+
}
|
|
11237
|
+
.intro {
|
|
11238
|
+
margin-top: 34px;
|
|
11239
|
+
}
|
|
11240
|
+
.headline {
|
|
11241
|
+
font-size: 40px;
|
|
11242
|
+
letter-spacing: -1.8px;
|
|
11243
|
+
}
|
|
11244
|
+
.headline br {
|
|
11245
|
+
display: none;
|
|
11246
|
+
}
|
|
11247
|
+
.lede {
|
|
11248
|
+
font-size: 13px;
|
|
11249
|
+
margin-top: 14px;
|
|
11250
|
+
max-width: 340px;
|
|
11251
|
+
}
|
|
11252
|
+
.rhythm {
|
|
11253
|
+
display: none;
|
|
11254
|
+
}
|
|
11255
|
+
.orbit {
|
|
11256
|
+
width: 320px;
|
|
11257
|
+
height: 320px;
|
|
11258
|
+
right: -180px;
|
|
11259
|
+
bottom: -215px;
|
|
11260
|
+
}
|
|
11261
|
+
.entry {
|
|
11262
|
+
padding: 32px 30px 36px;
|
|
11263
|
+
}
|
|
11264
|
+
.access {
|
|
11265
|
+
margin-bottom: 22px;
|
|
11266
|
+
}
|
|
11267
|
+
h1 {
|
|
11268
|
+
font-size: 28px;
|
|
11269
|
+
}
|
|
11270
|
+
.description {
|
|
11271
|
+
margin-bottom: 26px;
|
|
11272
|
+
}
|
|
11273
|
+
footer {
|
|
11274
|
+
max-width: 480px;
|
|
11275
|
+
padding-top: 16px;
|
|
11276
|
+
font-size: 9px;
|
|
11277
|
+
}
|
|
11278
|
+
.eyebrow {
|
|
11279
|
+
margin-bottom: 12px;
|
|
11280
|
+
}
|
|
11281
|
+
}
|
|
11282
|
+
@media (max-width: 360px) {
|
|
11283
|
+
body {
|
|
11284
|
+
padding: 14px 10px;
|
|
11285
|
+
}
|
|
11286
|
+
.story,
|
|
11287
|
+
.entry {
|
|
11288
|
+
padding-left: 22px;
|
|
11289
|
+
padding-right: 22px;
|
|
11290
|
+
}
|
|
11291
|
+
.headline {
|
|
11292
|
+
font-size: 36px;
|
|
11293
|
+
}
|
|
11294
|
+
footer {
|
|
11295
|
+
flex-wrap: wrap;
|
|
11296
|
+
gap: 6px;
|
|
11297
|
+
}
|
|
11298
|
+
}
|
|
11299
|
+
@media (prefers-reduced-motion: reduce) {
|
|
11300
|
+
*,
|
|
11301
|
+
*::before,
|
|
11302
|
+
*::after {
|
|
11303
|
+
animation: none !important;
|
|
11304
|
+
transition: none !important;
|
|
11305
|
+
}
|
|
11306
|
+
}
|
|
11307
|
+
@media (forced-colors: active) {
|
|
11308
|
+
main,
|
|
11309
|
+
input[type="password"],
|
|
11310
|
+
button,
|
|
11311
|
+
.access,
|
|
11312
|
+
.notice {
|
|
11313
|
+
border: 1px solid CanvasText;
|
|
11314
|
+
}
|
|
11315
|
+
.orbit {
|
|
11316
|
+
display: none;
|
|
11317
|
+
}
|
|
11318
|
+
.headline em {
|
|
11319
|
+
color: CanvasText;
|
|
11320
|
+
}
|
|
11321
|
+
}
|
|
11322
|
+
`;
|
|
11323
|
+
var AUTH_PAGE_CSP = `default-src 'none'; style-src 'sha256-${createHash9("sha256").update(styles).digest("base64")}'; base-uri 'none'; frame-ancestors 'none'; form-action 'self'`;
|
|
11324
|
+
function escapeAttr(value) {
|
|
11325
|
+
return value.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
11326
|
+
}
|
|
11327
|
+
function renderAuthPage(options) {
|
|
11328
|
+
return `<!doctype html>
|
|
11329
|
+
<html lang="en">
|
|
11330
|
+
<head>
|
|
11331
|
+
<meta charset="utf-8">
|
|
11332
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
11333
|
+
<meta name="color-scheme" content="dark">
|
|
11334
|
+
<title>Welcome to Cadence</title>
|
|
11335
|
+
<style>${styles}</style>
|
|
11336
|
+
</head>
|
|
11337
|
+
<body>
|
|
11338
|
+
<div class="shell">
|
|
11339
|
+
<main>
|
|
11340
|
+
<section class="story" aria-label="Cadence">
|
|
11341
|
+
<div class="brand"><svg viewBox="0 0 36 36" fill="none" aria-hidden="true"><rect x="1" y="1" width="34" height="34" rx="11" stroke="currentColor" stroke-opacity=".3"/><path d="M25 12a9 9 0 1 0 0 12M12 18h12" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>cadence</div>
|
|
11342
|
+
<div class="intro">
|
|
11343
|
+
<p class="eyebrow">A little focus. A lot of possibility.</p>
|
|
11344
|
+
<p class="headline">Find your flow.<br> Build <em>what’s next.</em></p>
|
|
11345
|
+
<p class="lede">A space for your ideas to become plans, and your plans to become something real.</p>
|
|
11346
|
+
</div>
|
|
11347
|
+
<div class="orbit" aria-hidden="true"><div class="satellite"></div></div>
|
|
11348
|
+
<div class="rhythm" aria-hidden="true">Think <span>↗</span> Create <span>↗</span> Keep going</div>
|
|
11349
|
+
</section>
|
|
11350
|
+
<section class="entry" aria-labelledby="welcome">
|
|
11351
|
+
<div class="access"><svg viewBox="0 0 20 20" fill="none" aria-hidden="true"><rect x="4" y="9" width="12" height="8" rx="2" stroke="currentColor" stroke-width="1.5"/><path d="M7 9V6a3 3 0 0 1 6 0v3" stroke="currentColor" stroke-width="1.5"/></svg>Private workspace</div>
|
|
11352
|
+
<h1 id="welcome">Welcome to Cadence.</h1>
|
|
11353
|
+
<p class="description">Your next idea starts here.<br>Enter your access key to step inside.</p>
|
|
11354
|
+
${options.authError ? '<p id="auth-notice" class="notice" role="alert">Access key was not accepted. Check the current key and try again.</p>' : ""}
|
|
11355
|
+
<form method="post" action="/auth">
|
|
11356
|
+
<input type="hidden" name="next" value="${escapeAttr(options.nextPath)}">
|
|
11357
|
+
<label for="key">Access key</label>
|
|
11358
|
+
<div class="field">
|
|
11359
|
+
<svg viewBox="0 0 24 24" fill="none" aria-hidden="true"><circle cx="8" cy="9" r="4" stroke="currentColor" stroke-width="1.6"/><path d="m11 12 8 8m-3-3 2-2m-5-1 2-2" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>
|
|
11360
|
+
<input id="key" name="password" type="password" placeholder="Enter your access key" autocomplete="current-password" required autofocus aria-describedby="key-hint${options.authError ? " auth-notice" : ""}"${options.authError ? ' aria-invalid="true"' : ""}>
|
|
11361
|
+
</div>
|
|
11362
|
+
<p id="key-hint" class="hint">Use the key provided by your Cadence server.</p>
|
|
11363
|
+
<button type="submit">Open workspace<svg viewBox="0 0 24 24" fill="none" aria-hidden="true"><path d="M4 12h15m-6-6 6 6-6 6" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"/></svg></button>
|
|
11364
|
+
</form>
|
|
11365
|
+
<p class="remember">Stay signed in on this browser for up to a year.<br>Your access key stays out of the address bar.</p>
|
|
11366
|
+
</section>
|
|
11367
|
+
</main>
|
|
11368
|
+
<footer><span>Cadence · A workspace for what’s next.</span><span>Your space. Your pace.</span></footer>
|
|
11369
|
+
</div>
|
|
11370
|
+
</body>
|
|
11371
|
+
</html>
|
|
11372
|
+
`;
|
|
11373
|
+
}
|
|
11374
|
+
|
|
10797
11375
|
// src/service/autostart.ts
|
|
10798
11376
|
import { spawnSync as spawnSync3 } from "node:child_process";
|
|
10799
11377
|
import {
|
|
@@ -12631,7 +13209,7 @@ function decodeStartupReport(value) {
|
|
|
12631
13209
|
}
|
|
12632
13210
|
|
|
12633
13211
|
// src/service/self-heal.ts
|
|
12634
|
-
import { createHash as
|
|
13212
|
+
import { createHash as createHash10, randomUUID as randomUUID11 } from "node:crypto";
|
|
12635
13213
|
import { lstatSync as lstatSync13, opendirSync as opendirSync7 } from "node:fs";
|
|
12636
13214
|
import { hostname as hostname7 } from "node:os";
|
|
12637
13215
|
import { join as join19 } from "node:path";
|
|
@@ -13322,7 +13900,7 @@ function liveReservations(c) {
|
|
|
13322
13900
|
return out;
|
|
13323
13901
|
}
|
|
13324
13902
|
function projectFiles(c, root) {
|
|
13325
|
-
const privateRoot = join19(c.files.namespace,
|
|
13903
|
+
const privateRoot = join19(c.files.namespace, createHash10("sha256").update(root).digest("hex"));
|
|
13326
13904
|
return {
|
|
13327
13905
|
root,
|
|
13328
13906
|
privateRoot,
|
|
@@ -14535,9 +15113,9 @@ class CadencePreferences {
|
|
|
14535
15113
|
}
|
|
14536
15114
|
|
|
14537
15115
|
// src/conversation-identity.ts
|
|
14538
|
-
import { createHash as
|
|
15116
|
+
import { createHash as createHash11 } from "node:crypto";
|
|
14539
15117
|
function conversationIdentity(identity) {
|
|
14540
|
-
const h =
|
|
15118
|
+
const h = createHash11("sha256").update(identity).digest("hex");
|
|
14541
15119
|
return `${h.slice(0, 8)}-${h.slice(8, 12)}-4${h.slice(13, 16)}-8${h.slice(17, 20)}-${h.slice(20, 32)}`;
|
|
14542
15120
|
}
|
|
14543
15121
|
|
|
@@ -15526,7 +16104,7 @@ class ConversationControls {
|
|
|
15526
16104
|
}
|
|
15527
16105
|
|
|
15528
16106
|
// src/service/workbench-files.ts
|
|
15529
|
-
import { createHash as
|
|
16107
|
+
import { createHash as createHash12 } from "node:crypto";
|
|
15530
16108
|
import {
|
|
15531
16109
|
closeSync as closeSync7,
|
|
15532
16110
|
constants as constants7,
|
|
@@ -15689,7 +16267,7 @@ class WorkbenchFiles {
|
|
|
15689
16267
|
kind: "file-part",
|
|
15690
16268
|
path,
|
|
15691
16269
|
size: stat.size,
|
|
15692
|
-
version:
|
|
16270
|
+
version: createHash12("sha256").update(`${stat.dev}:${stat.ino}:${stat.size}:${stat.mtimeMs}`).digest("hex").slice(0, 32),
|
|
15693
16271
|
data: buffer.toString("base64"),
|
|
15694
16272
|
next: end < stat.size ? end : null
|
|
15695
16273
|
};
|
|
@@ -15899,7 +16477,7 @@ async function readGatewayModels(project, input, secrets, read) {
|
|
|
15899
16477
|
}
|
|
15900
16478
|
|
|
15901
16479
|
// src/service/http.ts
|
|
15902
|
-
import { createHash as
|
|
16480
|
+
import { createHash as createHash13, randomUUID as randomUUID13 } from "node:crypto";
|
|
15903
16481
|
import {
|
|
15904
16482
|
createServer
|
|
15905
16483
|
} from "node:http";
|
|
@@ -15988,7 +16566,7 @@ class ServiceHttpServer {
|
|
|
15988
16566
|
this.assets.set(asset.path, {
|
|
15989
16567
|
...asset,
|
|
15990
16568
|
bytes: Uint8Array.from(asset.bytes),
|
|
15991
|
-
etag: `"${
|
|
16569
|
+
etag: `"${createHash13("sha256").update(asset.bytes).digest("hex")}"`
|
|
15992
16570
|
});
|
|
15993
16571
|
}
|
|
15994
16572
|
this.server = createServer({
|
|
@@ -16216,11 +16794,17 @@ Content-Length: 0\r
|
|
|
16216
16794
|
res.destroy();
|
|
16217
16795
|
}, LIMITS.downloadIdleMs);
|
|
16218
16796
|
const resetIdle = () => timer.refresh();
|
|
16797
|
+
let boundary;
|
|
16798
|
+
let url;
|
|
16219
16799
|
try {
|
|
16220
|
-
|
|
16800
|
+
boundary = requestBoundary(req, this.policy, this.origin);
|
|
16221
16801
|
const target = req.url ?? "";
|
|
16222
16802
|
assertRequestTarget(target);
|
|
16223
|
-
|
|
16803
|
+
url = new URL(target, this.origin);
|
|
16804
|
+
if (target === "/auth" && req.method === "POST") {
|
|
16805
|
+
await this.login(req, res, boundary, abort.signal);
|
|
16806
|
+
return;
|
|
16807
|
+
}
|
|
16224
16808
|
if (url.searchParams.has("token")) {
|
|
16225
16809
|
if (req.method !== "GET" || !target.startsWith("/?token=") || [...url.searchParams.keys()].length !== 1)
|
|
16226
16810
|
throw new ContractError("invalid");
|
|
@@ -16237,8 +16821,18 @@ Content-Length: 0\r
|
|
|
16237
16821
|
return;
|
|
16238
16822
|
}
|
|
16239
16823
|
if (target === "/" && req.method === "GET") {
|
|
16240
|
-
|
|
16241
|
-
|
|
16824
|
+
if (!this.accepting)
|
|
16825
|
+
unavailable();
|
|
16826
|
+
try {
|
|
16827
|
+
this.options.auth.authenticate(boundary, randomUUID13(), false);
|
|
16828
|
+
} catch (e) {
|
|
16829
|
+
if (e instanceof ContractError && e.code === "unauthenticated")
|
|
16830
|
+
return this.unauthorized(res, boundary, url);
|
|
16831
|
+
throw e;
|
|
16832
|
+
}
|
|
16833
|
+
res.statusCode = 303;
|
|
16834
|
+
res.setHeader("Location", "/app");
|
|
16835
|
+
res.end();
|
|
16242
16836
|
return;
|
|
16243
16837
|
}
|
|
16244
16838
|
if (target.startsWith("/local/v1/admin/")) {
|
|
@@ -16328,6 +16922,10 @@ Content-Length: 0\r
|
|
|
16328
16922
|
res.destroy();
|
|
16329
16923
|
else {
|
|
16330
16924
|
const code2 = e instanceof ContractError ? e.code : "unavailable";
|
|
16925
|
+
if (code2 === "unauthenticated" && boundary && url) {
|
|
16926
|
+
this.unauthorized(res, boundary, url);
|
|
16927
|
+
return;
|
|
16928
|
+
}
|
|
16331
16929
|
res.setHeader("Connection", "close");
|
|
16332
16930
|
send(res, errorStatus(code2), refusal(code2, dispatched && !(e instanceof UnacceptedConversationCommand)));
|
|
16333
16931
|
}
|
|
@@ -16339,6 +16937,59 @@ Content-Length: 0\r
|
|
|
16339
16937
|
this.reads--;
|
|
16340
16938
|
}
|
|
16341
16939
|
}
|
|
16940
|
+
async login(req, res, boundary, signal) {
|
|
16941
|
+
if (!this.accepting)
|
|
16942
|
+
unavailable();
|
|
16943
|
+
if (!boundary.headers.has("origin"))
|
|
16944
|
+
throw new ContractError("forbidden");
|
|
16945
|
+
if (this.bodies >= LIMITS.admissionCount)
|
|
16946
|
+
throw new ContractError("capacity");
|
|
16947
|
+
this.bodies++;
|
|
16948
|
+
let form;
|
|
16949
|
+
try {
|
|
16950
|
+
form = await readLoginForm(req, signal);
|
|
16951
|
+
} finally {
|
|
16952
|
+
this.bodies--;
|
|
16953
|
+
}
|
|
16954
|
+
if (!this.accepting || signal.aborted)
|
|
16955
|
+
unavailable();
|
|
16956
|
+
const { password: submitted, next } = form;
|
|
16957
|
+
try {
|
|
16958
|
+
res.setHeader("Set-Cookie", this.options.auth.login(submitted, boundary));
|
|
16959
|
+
res.statusCode = 303;
|
|
16960
|
+
res.setHeader("Location", next);
|
|
16961
|
+
res.end();
|
|
16962
|
+
} catch (e) {
|
|
16963
|
+
const code2 = e instanceof ContractError ? e.code : "unavailable";
|
|
16964
|
+
if (code2 === "unauthenticated") {
|
|
16965
|
+
if (this.options.auth.carriesCookie(boundary.headers.get("cookie")))
|
|
16966
|
+
res.setHeader("Set-Cookie", this.options.auth.clearCookie(boundary.secure));
|
|
16967
|
+
res.statusCode = 303;
|
|
16968
|
+
res.setHeader("Location", loginRetryPath(next));
|
|
16969
|
+
res.end();
|
|
16970
|
+
return;
|
|
16971
|
+
}
|
|
16972
|
+
res.setHeader("Connection", "close");
|
|
16973
|
+
send(res, errorStatus(code2), refusal(code2));
|
|
16974
|
+
}
|
|
16975
|
+
}
|
|
16976
|
+
unauthorized(res, boundary, url) {
|
|
16977
|
+
if (this.options.auth.carriesCookie(boundary.headers.get("cookie")))
|
|
16978
|
+
res.setHeader("Set-Cookie", this.options.auth.clearCookie(boundary.secure));
|
|
16979
|
+
if ((boundary.headers.get("accept") ?? "").includes("text/html")) {
|
|
16980
|
+
res.setHeader("Referrer-Policy", "same-origin");
|
|
16981
|
+
res.setHeader("Content-Security-Policy", AUTH_PAGE_CSP);
|
|
16982
|
+
res.setHeader("Content-Type", "text/html; charset=utf-8");
|
|
16983
|
+
res.statusCode = 401;
|
|
16984
|
+
res.end(renderAuthPage({
|
|
16985
|
+
authError: url.searchParams.has("auth_error"),
|
|
16986
|
+
nextPath: loginNextPath(url)
|
|
16987
|
+
}));
|
|
16988
|
+
} else {
|
|
16989
|
+
res.setHeader("Connection", "close");
|
|
16990
|
+
send(res, 401, refusal("unauthenticated"));
|
|
16991
|
+
}
|
|
16992
|
+
}
|
|
16342
16993
|
async manage(req, res, boundary, signal) {
|
|
16343
16994
|
const operation = req.url?.slice("/local/v1/admin/".length);
|
|
16344
16995
|
if (![
|
|
@@ -16535,7 +17186,7 @@ Content-Length: 0\r
|
|
|
16535
17186
|
res.setHeader("Content-Type", operation === "download" && request2.format === "markdown" ? "text/markdown; charset=utf-8" : "application/x-ndjson; charset=utf-8");
|
|
16536
17187
|
res.setHeader("Content-Disposition", `attachment; filename="cadence-export.${operation === "download" && request2.format === "markdown" ? "md" : "ndjson"}"`);
|
|
16537
17188
|
let trailer;
|
|
16538
|
-
const digest =
|
|
17189
|
+
const digest = createHash13("sha256");
|
|
16539
17190
|
const write2 = async (frame) => {
|
|
16540
17191
|
const data2 = Buffer.from(operation === "download" ? encodeExportFrame(frame, request2.format) : `${canonicalJson(frame)}
|
|
16541
17192
|
`);
|
|
@@ -16773,7 +17424,7 @@ Content-Length: 0\r
|
|
|
16773
17424
|
|
|
16774
17425
|
// src/service/model-preview-process.ts
|
|
16775
17426
|
import { spawn as spawn4 } from "node:child_process";
|
|
16776
|
-
import { createHash as
|
|
17427
|
+
import { createHash as createHash14 } from "node:crypto";
|
|
16777
17428
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
16778
17429
|
|
|
16779
17430
|
// src/service/model-preview-protocol.ts
|
|
@@ -16823,7 +17474,7 @@ class ModelPreviewProcesses {
|
|
|
16823
17474
|
});
|
|
16824
17475
|
const body = canonicalJson(input, PREVIEW_INPUT_BYTES);
|
|
16825
17476
|
const env = captureEnvironment(hostEnvironment(environment2));
|
|
16826
|
-
const key =
|
|
17477
|
+
const key = createHash14("sha256").update(body).update(JSON.stringify(env)).digest("hex");
|
|
16827
17478
|
const previous = this.jobs.get(key);
|
|
16828
17479
|
if (previous)
|
|
16829
17480
|
return previous.result;
|
|
@@ -16973,7 +17624,7 @@ async function createGateway(value, hostUrl, source) {
|
|
|
16973
17624
|
const input = decodeGatewayInput(value), store = new GatewayStore(input.serverConfig, input.stateHome);
|
|
16974
17625
|
const web = loadWebAssets(source?.webDirectory);
|
|
16975
17626
|
const build2 = {
|
|
16976
|
-
contractHash: "
|
|
17627
|
+
contractHash: "d70dd3e63843be7df42ff10943fcdc78bcd27b881b0ac8222526e8dad7b0e6e2",
|
|
16977
17628
|
assets: {
|
|
16978
17629
|
sourceHash: web.manifest.sourceHash,
|
|
16979
17630
|
contractHash: web.manifest.contractHash,
|
|
@@ -17425,6 +18076,51 @@ Content-Length: 0\r
|
|
|
17425
18076
|
const match = /^\/projects\/([a-f0-9]{64})(\/.*)$/.exec(raw);
|
|
17426
18077
|
return match ? { id: decodeHash(match[1]), tail: match[2] } : null;
|
|
17427
18078
|
}
|
|
18079
|
+
async function login(req, res, boundary) {
|
|
18080
|
+
assert();
|
|
18081
|
+
if (!boundary.headers.has("origin"))
|
|
18082
|
+
throw new ContractError("forbidden");
|
|
18083
|
+
const { password: submitted, next } = await readLoginForm(req);
|
|
18084
|
+
assert();
|
|
18085
|
+
try {
|
|
18086
|
+
res.setHeader("Set-Cookie", auth.login(submitted, boundary));
|
|
18087
|
+
res.statusCode = 303;
|
|
18088
|
+
res.setHeader("Location", next);
|
|
18089
|
+
res.end();
|
|
18090
|
+
} catch (e) {
|
|
18091
|
+
const code2 = e instanceof ContractError ? e.code : "unavailable";
|
|
18092
|
+
if (code2 === "unauthenticated") {
|
|
18093
|
+
if (auth.carriesCookie(boundary.headers.get("cookie")))
|
|
18094
|
+
res.setHeader("Set-Cookie", auth.clearCookie(boundary.secure));
|
|
18095
|
+
res.statusCode = 303;
|
|
18096
|
+
res.setHeader("Location", loginRetryPath(next));
|
|
18097
|
+
res.end();
|
|
18098
|
+
return;
|
|
18099
|
+
}
|
|
18100
|
+
res.setHeader("Connection", "close");
|
|
18101
|
+
reply(res, code2 === "forbidden" ? 403 : 400, {
|
|
18102
|
+
kind: "error",
|
|
18103
|
+
error: publicError(code2)
|
|
18104
|
+
});
|
|
18105
|
+
}
|
|
18106
|
+
}
|
|
18107
|
+
function unauthorized(res, boundary, url) {
|
|
18108
|
+
if (auth.carriesCookie(boundary.headers.get("cookie")))
|
|
18109
|
+
res.setHeader("Set-Cookie", auth.clearCookie(boundary.secure));
|
|
18110
|
+
if ((boundary.headers.get("accept") ?? "").includes("text/html")) {
|
|
18111
|
+
res.setHeader("Referrer-Policy", "same-origin");
|
|
18112
|
+
res.setHeader("Content-Security-Policy", AUTH_PAGE_CSP);
|
|
18113
|
+
res.setHeader("Content-Type", "text/html; charset=utf-8");
|
|
18114
|
+
res.statusCode = 401;
|
|
18115
|
+
res.end(renderAuthPage({
|
|
18116
|
+
authError: url.searchParams.has("auth_error"),
|
|
18117
|
+
nextPath: loginNextPath(url)
|
|
18118
|
+
}));
|
|
18119
|
+
} else {
|
|
18120
|
+
res.setHeader("Connection", "close");
|
|
18121
|
+
reply(res, 401, { kind: "error", error: publicError("unauthenticated") });
|
|
18122
|
+
}
|
|
18123
|
+
}
|
|
17428
18124
|
async function handle(req, res) {
|
|
17429
18125
|
let effect = false;
|
|
17430
18126
|
if (++pending > 64) {
|
|
@@ -17433,10 +18129,17 @@ Content-Length: 0\r
|
|
|
17433
18129
|
return;
|
|
17434
18130
|
}
|
|
17435
18131
|
fixedHeaders(res);
|
|
18132
|
+
let boundary;
|
|
18133
|
+
let url;
|
|
17436
18134
|
try {
|
|
17437
|
-
|
|
18135
|
+
boundary = requestBoundary(req, input.policy, endpoint2);
|
|
18136
|
+
const raw = req.url ?? "";
|
|
17438
18137
|
assertRequestTarget(raw);
|
|
17439
|
-
|
|
18138
|
+
url = new URL(raw, endpoint2);
|
|
18139
|
+
if (raw === "/auth" && req.method === "POST") {
|
|
18140
|
+
await login(req, res, boundary);
|
|
18141
|
+
return;
|
|
18142
|
+
}
|
|
17440
18143
|
if (raw === "/healthz" && req.method === "GET") {
|
|
17441
18144
|
reply(res, 200, { status: "ok" });
|
|
17442
18145
|
return;
|
|
@@ -17452,8 +18155,16 @@ Content-Length: 0\r
|
|
|
17452
18155
|
return;
|
|
17453
18156
|
}
|
|
17454
18157
|
if (raw === "/" && req.method === "GET") {
|
|
17455
|
-
|
|
17456
|
-
|
|
18158
|
+
try {
|
|
18159
|
+
auth.authenticate(boundary, randomUUID14(), false);
|
|
18160
|
+
} catch (e) {
|
|
18161
|
+
if (e instanceof ContractError && e.code === "unauthenticated")
|
|
18162
|
+
return unauthorized(res, boundary, url);
|
|
18163
|
+
throw e;
|
|
18164
|
+
}
|
|
18165
|
+
res.statusCode = 303;
|
|
18166
|
+
res.setHeader("Location", "/app");
|
|
18167
|
+
res.end();
|
|
17457
18168
|
return;
|
|
17458
18169
|
}
|
|
17459
18170
|
if (raw.startsWith("/local/v1/admin/")) {
|
|
@@ -17771,6 +18482,8 @@ Content-Length: 0\r
|
|
|
17771
18482
|
const code2 = error instanceof ContractError ? error.code : "unavailable";
|
|
17772
18483
|
if (res.headersSent)
|
|
17773
18484
|
res.destroy();
|
|
18485
|
+
else if (code2 === "unauthenticated" && boundary && url)
|
|
18486
|
+
unauthorized(res, boundary, url);
|
|
17774
18487
|
else
|
|
17775
18488
|
reply(res, code2 === "unauthenticated" ? 401 : code2 === "forbidden" ? 403 : 400, {
|
|
17776
18489
|
kind: "error",
|
|
@@ -17859,7 +18572,7 @@ import { join as join45 } from "node:path";
|
|
|
17859
18572
|
import { fileURLToPath as fileURLToPath8 } from "node:url";
|
|
17860
18573
|
|
|
17861
18574
|
// src/agent-registry.ts
|
|
17862
|
-
import { createHash as
|
|
18575
|
+
import { createHash as createHash15 } from "node:crypto";
|
|
17863
18576
|
import { fileURLToPath as fileURLToPath5 } from "node:url";
|
|
17864
18577
|
var AGENT_FILES = [
|
|
17865
18578
|
"design-explorer.md",
|
|
@@ -17876,7 +18589,7 @@ function loadAgentDefinitions() {
|
|
|
17876
18589
|
role: fileName.replace(/\.md$/, ""),
|
|
17877
18590
|
fileName,
|
|
17878
18591
|
path,
|
|
17879
|
-
sha256:
|
|
18592
|
+
sha256: createHash15("sha256").update(data2).digest("hex"),
|
|
17880
18593
|
bytes: data2.length,
|
|
17881
18594
|
content: data2.toString("utf8")
|
|
17882
18595
|
};
|
|
@@ -18131,7 +18844,7 @@ class HistoryLive {
|
|
|
18131
18844
|
}
|
|
18132
18845
|
|
|
18133
18846
|
// src/history/navigation.ts
|
|
18134
|
-
import { createHash as
|
|
18847
|
+
import { createHash as createHash16 } from "node:crypto";
|
|
18135
18848
|
import { lstatSync as lstatSync18 } from "node:fs";
|
|
18136
18849
|
import { dirname as dirname18, join as join29 } from "node:path";
|
|
18137
18850
|
|
|
@@ -19358,7 +20071,7 @@ class HistoryNavigation {
|
|
|
19358
20071
|
continue;
|
|
19359
20072
|
}
|
|
19360
20073
|
let pending = Buffer.alloc(0), at2 = offset, bodyBytes = 0;
|
|
19361
|
-
const checksum =
|
|
20074
|
+
const checksum = createHash16("sha256"), rows = [];
|
|
19362
20075
|
while (at2 < size2) {
|
|
19363
20076
|
const chunk = this.block(path, at2, size2, budget);
|
|
19364
20077
|
at2 += chunk.length;
|
|
@@ -19861,7 +20574,7 @@ function navigationKeys(row) {
|
|
|
19861
20574
|
}
|
|
19862
20575
|
|
|
19863
20576
|
// src/history/projection.ts
|
|
19864
|
-
import { createHash as
|
|
20577
|
+
import { createHash as createHash22 } from "node:crypto";
|
|
19865
20578
|
|
|
19866
20579
|
// src/history/task-folds.ts
|
|
19867
20580
|
var TASKS = 1024;
|
|
@@ -20204,17 +20917,17 @@ function materializeEntity(s, sources) {
|
|
|
20204
20917
|
}
|
|
20205
20918
|
|
|
20206
20919
|
// src/history/export.ts
|
|
20207
|
-
import { createHash as
|
|
20920
|
+
import { createHash as createHash20, randomUUID as randomUUID15 } from "node:crypto";
|
|
20208
20921
|
import { readFileSync as readFileSync5 } from "node:fs";
|
|
20209
20922
|
|
|
20210
20923
|
// src/history/search.ts
|
|
20211
|
-
import { createHash as
|
|
20924
|
+
import { createHash as createHash19 } from "node:crypto";
|
|
20212
20925
|
|
|
20213
20926
|
// src/history/read-proof.ts
|
|
20214
20927
|
import {
|
|
20215
20928
|
createCipheriv,
|
|
20216
20929
|
createDecipheriv,
|
|
20217
|
-
createHash as
|
|
20930
|
+
createHash as createHash17,
|
|
20218
20931
|
randomBytes as randomBytes5
|
|
20219
20932
|
} from "node:crypto";
|
|
20220
20933
|
var PREFIX = "rp1.";
|
|
@@ -20266,7 +20979,7 @@ class HistoryReadProof {
|
|
|
20266
20979
|
root: this.files.format.rootIdentity,
|
|
20267
20980
|
format: material.formatStamp,
|
|
20268
20981
|
key: material.keyStamp,
|
|
20269
|
-
request:
|
|
20982
|
+
request: createHash17("sha256").update(canonicalJson(readIdentity(request3))).digest("hex")
|
|
20270
20983
|
}));
|
|
20271
20984
|
}
|
|
20272
20985
|
seal(context, plaintext, budget) {
|
|
@@ -21038,11 +21751,11 @@ function decodeRetainedProgress(value) {
|
|
|
21038
21751
|
}
|
|
21039
21752
|
|
|
21040
21753
|
// src/history/retained-traversal.ts
|
|
21041
|
-
import { createHash as
|
|
21754
|
+
import { createHash as createHash18 } from "node:crypto";
|
|
21042
21755
|
function bad5() {
|
|
21043
21756
|
throw new ContractError("corrupt-selected");
|
|
21044
21757
|
}
|
|
21045
|
-
var fingerprint = (v) =>
|
|
21758
|
+
var fingerprint = (v) => createHash18("sha256").update(canonicalJson(v)).digest("hex");
|
|
21046
21759
|
var ready = (v) => {
|
|
21047
21760
|
const s = v.state;
|
|
21048
21761
|
if (s.phase !== "ready")
|
|
@@ -21398,11 +22111,11 @@ var digits = (id) => {
|
|
|
21398
22111
|
return s.slice(0, 12) + s.slice(13, 16) + s.slice(17);
|
|
21399
22112
|
};
|
|
21400
22113
|
var publicTextRef = (id, label, text2, field, batch, row, slot) => ({
|
|
21401
|
-
recordId: uuid(address(batch.pointer).toString(16).padStart(14, "0") +
|
|
22114
|
+
recordId: uuid(address(batch.pointer).toString(16).padStart(14, "0") + createHash19("sha256").update(`${id}/${label}`).digest("hex").slice(0, 16)),
|
|
21402
22115
|
version: batch.rows.indexOf(row) * EVENT_SLOTS + slot + 1,
|
|
21403
22116
|
field,
|
|
21404
22117
|
bytes: Buffer.byteLength(text2),
|
|
21405
|
-
sha256:
|
|
22118
|
+
sha256: createHash19("sha256").update(text2).digest("hex")
|
|
21406
22119
|
});
|
|
21407
22120
|
var initial = () => ({
|
|
21408
22121
|
pos: { segment: 1, offset: 0 },
|
|
@@ -21418,7 +22131,7 @@ function scanCursor(base, p) {
|
|
|
21418
22131
|
const snapshot = p.snapshot.toString(16).padStart(14, "0");
|
|
21419
22132
|
if (snapshot.length !== 14)
|
|
21420
22133
|
throw new ContractError("capacity");
|
|
21421
|
-
const binding =
|
|
22134
|
+
const binding = createHash19("sha256").update(canonicalJson({
|
|
21422
22135
|
...readIdentity(base),
|
|
21423
22136
|
recordId: null,
|
|
21424
22137
|
recordVersion: version,
|
|
@@ -21759,7 +22472,7 @@ class RetainedScan {
|
|
|
21759
22472
|
graph: {
|
|
21760
22473
|
recordId: v.intent.operationId,
|
|
21761
22474
|
revision: graph.revision,
|
|
21762
|
-
sha256:
|
|
22475
|
+
sha256: createHash19("sha256").update(canonicalJson(graph)).digest("hex")
|
|
21763
22476
|
}
|
|
21764
22477
|
},
|
|
21765
22478
|
graph
|
|
@@ -22058,7 +22771,7 @@ async function searchQuantum(reader, value, limit = LIMITS.pageEntries) {
|
|
|
22058
22771
|
// src/history/export.ts
|
|
22059
22772
|
var exporterIdentity;
|
|
22060
22773
|
function buildIdentity() {
|
|
22061
|
-
exporterIdentity ??=
|
|
22774
|
+
exporterIdentity ??= createHash20("sha256").update(readFileSync5(new URL(import.meta.url))).digest("hex");
|
|
22062
22775
|
return exporterIdentity;
|
|
22063
22776
|
}
|
|
22064
22777
|
function aborted(signal) {
|
|
@@ -22118,7 +22831,7 @@ Coverage: ${canonicalJson(event.coverage)}
|
|
|
22118
22831
|
}
|
|
22119
22832
|
}
|
|
22120
22833
|
async function* exportHistory(projection, input, signal) {
|
|
22121
|
-
const request3 = decodeExportRequest(input), exportId = randomUUID15(), digest =
|
|
22834
|
+
const request3 = decodeExportRequest(input), exportId = randomUUID15(), digest = createHash20("sha256");
|
|
22122
22835
|
let ordinal = 0, encodedBytes = 0, coverage = { ...COMPLETE, omissions: [] };
|
|
22123
22836
|
const frame = (event) => {
|
|
22124
22837
|
aborted(signal);
|
|
@@ -22187,7 +22900,7 @@ async function* exportHistory(projection, input, signal) {
|
|
|
22187
22900
|
const { detail, owner } = item, original = open2.get(detail.content.recordId);
|
|
22188
22901
|
if (detail.content.bytes ? !original || original.bytes !== detail.content.bytes || original.content !== canonicalJson(detail.content) : original !== undefined)
|
|
22189
22902
|
throw new ContractError("corrupt-selected");
|
|
22190
|
-
if ((original?.hash ??
|
|
22903
|
+
if ((original?.hash ?? createHash20("sha256")).digest("hex") !== detail.content.sha256)
|
|
22191
22904
|
throw new ContractError("corrupt-selected");
|
|
22192
22905
|
open2.delete(detail.content.recordId);
|
|
22193
22906
|
const events = [];
|
|
@@ -22218,7 +22931,7 @@ async function* exportHistory(projection, input, signal) {
|
|
|
22218
22931
|
coverage = combineCoverage(coverage, item.coverage);
|
|
22219
22932
|
const length = Buffer.byteLength(item.text);
|
|
22220
22933
|
if (item.inline) {
|
|
22221
|
-
if (item.start !== 0 || length !== item.content.bytes ||
|
|
22934
|
+
if (item.start !== 0 || length !== item.content.bytes || createHash20("sha256").update(item.text).digest("hex") !== item.content.sha256)
|
|
22222
22935
|
throw new ContractError("corrupt-selected");
|
|
22223
22936
|
} else {
|
|
22224
22937
|
let original = open2.get(item.content.recordId);
|
|
@@ -22228,7 +22941,7 @@ async function* exportHistory(projection, input, signal) {
|
|
|
22228
22941
|
original = {
|
|
22229
22942
|
bytes: 0,
|
|
22230
22943
|
content: canonicalJson(item.content),
|
|
22231
|
-
hash:
|
|
22944
|
+
hash: createHash20("sha256")
|
|
22232
22945
|
};
|
|
22233
22946
|
open2.set(item.content.recordId, original);
|
|
22234
22947
|
}
|
|
@@ -22343,7 +23056,7 @@ async function* exportHistory(projection, input, signal) {
|
|
|
22343
23056
|
}
|
|
22344
23057
|
|
|
22345
23058
|
// src/history/list-progress.ts
|
|
22346
|
-
import { createHash as
|
|
23059
|
+
import { createHash as createHash21 } from "node:crypto";
|
|
22347
23060
|
|
|
22348
23061
|
// src/history/detail-progress.ts
|
|
22349
23062
|
function bad7() {
|
|
@@ -22817,7 +23530,7 @@ function fits(link, scope) {
|
|
|
22817
23530
|
return scope.kind === "workspace" || (scope.kind === "task" ? link.taskId === scope.id : scope.kind === "run" ? link.runId === scope.id : link.childRunId === scope.id);
|
|
22818
23531
|
}
|
|
22819
23532
|
function nextAfter(request3, n) {
|
|
22820
|
-
const h =
|
|
23533
|
+
const h = createHash21("sha256").update(canonicalJson({ ...readIdentity(request3), after: null, ordinal: n })).digest("hex");
|
|
22821
23534
|
return {
|
|
22822
23535
|
recordId: `${h.slice(0, 8)}-${h.slice(8, 12)}-4${h.slice(13, 16)}-8${h.slice(17, 20)}-${h.slice(20, 32)}`,
|
|
22823
23536
|
version: 1,
|
|
@@ -23201,7 +23914,7 @@ async function read(p, request3, entity) {
|
|
|
23201
23914
|
const tasks = [...p.environment.legacyTasks(budget)].sort((a, b) => a.id < b.id ? -1 : a.id > b.id ? 1 : 0);
|
|
23202
23915
|
if (tasks.length > 1000)
|
|
23203
23916
|
throw new ContractError("capacity");
|
|
23204
|
-
const sum =
|
|
23917
|
+
const sum = createHash21("sha256");
|
|
23205
23918
|
for (const task2 of tasks) {
|
|
23206
23919
|
budget.reserve(0);
|
|
23207
23920
|
sum.update(JSON.stringify({
|
|
@@ -23214,7 +23927,7 @@ async function read(p, request3, entity) {
|
|
|
23214
23927
|
if (s.legacy > tasks.length)
|
|
23215
23928
|
bad9();
|
|
23216
23929
|
if (!s.legacyIdentity && request3.after?.version === Number.MAX_SAFE_INTEGER) {
|
|
23217
|
-
const h =
|
|
23930
|
+
const h = createHash21("sha256").update(canonicalJson({
|
|
23218
23931
|
...readIdentity(request3),
|
|
23219
23932
|
after: null,
|
|
23220
23933
|
legacy: s.legacy === 0 ? "begin" : identity,
|
|
@@ -23494,7 +24207,7 @@ class HistoryProjection {
|
|
|
23494
24207
|
};
|
|
23495
24208
|
cursor(request3, pos, row, item) {
|
|
23496
24209
|
const offset = pos.offset * (LIMITS.segmentRecords + 1) * ROW_SLOTS + row * ROW_SLOTS + item;
|
|
23497
|
-
const digest =
|
|
24210
|
+
const digest = createHash22("sha256").update(canonicalJson({
|
|
23498
24211
|
...readIdentity(request3),
|
|
23499
24212
|
after: null,
|
|
23500
24213
|
position: { ...pos, row, item }
|
|
@@ -23685,7 +24398,7 @@ class HistoryProjection {
|
|
|
23685
24398
|
if (legacyPhase)
|
|
23686
24399
|
this.navigation.snapshot(snapshot, budget);
|
|
23687
24400
|
const cursor = (offset2, identity2) => {
|
|
23688
|
-
const digest2 =
|
|
24401
|
+
const digest2 = createHash22("sha256").update(canonicalJson({ ...request3, after: null, legacy: identity2, offset: offset2 })).digest("hex");
|
|
23689
24402
|
return {
|
|
23690
24403
|
recordId: `${digest2.slice(0, 8)}-${digest2.slice(8, 12)}-4${digest2.slice(13, 16)}-8${digest2.slice(17, 20)}-${digest2.slice(20, 32)}`,
|
|
23691
24404
|
version: legacyVersion,
|
|
@@ -23712,7 +24425,7 @@ class HistoryProjection {
|
|
|
23712
24425
|
}
|
|
23713
24426
|
if (legacy.length > 1000)
|
|
23714
24427
|
throw new ContractError("capacity");
|
|
23715
|
-
const items = [...legacy].sort((a, b) => a.id < b.id ? -1 : a.id > b.id ? 1 : 0), digest =
|
|
24428
|
+
const items = [...legacy].sort((a, b) => a.id < b.id ? -1 : a.id > b.id ? 1 : 0), digest = createHash22("sha256");
|
|
23716
24429
|
for (const item of items) {
|
|
23717
24430
|
budget.reserve(0);
|
|
23718
24431
|
if (Buffer.byteLength(item.goal) > 8192)
|
|
@@ -23902,7 +24615,7 @@ class HistoryProjection {
|
|
|
23902
24615
|
}
|
|
23903
24616
|
|
|
23904
24617
|
// src/history/reader.ts
|
|
23905
|
-
import { createHash as
|
|
24618
|
+
import { createHash as createHash23 } from "node:crypto";
|
|
23906
24619
|
import { existsSync as existsSync3 } from "node:fs";
|
|
23907
24620
|
import { join as join30 } from "node:path";
|
|
23908
24621
|
|
|
@@ -24564,7 +25277,7 @@ class HistoryReader {
|
|
|
24564
25277
|
}
|
|
24565
25278
|
}
|
|
24566
25279
|
const text2 = Buffer.concat(pieces);
|
|
24567
|
-
if (end !== detail.content.bytes ||
|
|
25280
|
+
if (end !== detail.content.bytes || createHash23("sha256").update(text2).digest("hex") !== detail.content.sha256)
|
|
24568
25281
|
return;
|
|
24569
25282
|
return { detail, bytes: text2 };
|
|
24570
25283
|
} catch {
|
|
@@ -24599,7 +25312,7 @@ class HistoryReader {
|
|
|
24599
25312
|
if (!current2 || current2.length < expected.bytes || hash(current2.subarray(0, expected.bytes)) !== expected.identity)
|
|
24600
25313
|
throw new ContractError("corrupt-selected");
|
|
24601
25314
|
}
|
|
24602
|
-
const checksum =
|
|
25315
|
+
const checksum = createHash23("sha256");
|
|
24603
25316
|
let bytes = 0;
|
|
24604
25317
|
let cached;
|
|
24605
25318
|
for (const e of locator.chunks) {
|
|
@@ -24873,16 +25586,16 @@ class HistoryReader {
|
|
|
24873
25586
|
}
|
|
24874
25587
|
|
|
24875
25588
|
// src/history/recovery.ts
|
|
24876
|
-
import { createHash as
|
|
25589
|
+
import { createHash as createHash27, randomUUID as randomUUID19 } from "node:crypto";
|
|
24877
25590
|
import { lstatSync as lstatSync19, opendirSync as opendirSync11 } from "node:fs";
|
|
24878
25591
|
import { join as join34, relative as relative7 } from "node:path";
|
|
24879
25592
|
|
|
24880
25593
|
// src/history/writer.ts
|
|
24881
|
-
import { createHash as
|
|
25594
|
+
import { createHash as createHash26, randomUUID as randomUUID18 } from "node:crypto";
|
|
24882
25595
|
import { join as join33 } from "node:path";
|
|
24883
25596
|
|
|
24884
25597
|
// src/task-store.ts
|
|
24885
|
-
import { createHash as
|
|
25598
|
+
import { createHash as createHash24, randomUUID as randomUUID16 } from "node:crypto";
|
|
24886
25599
|
import {
|
|
24887
25600
|
closeSync as closeSync8,
|
|
24888
25601
|
fsyncSync as fsyncSync4,
|
|
@@ -24970,7 +25683,7 @@ function recordText(record3) {
|
|
|
24970
25683
|
`;
|
|
24971
25684
|
}
|
|
24972
25685
|
function contentIdentity(text2) {
|
|
24973
|
-
return
|
|
25686
|
+
return createHash24("sha256").update(text2).digest("hex");
|
|
24974
25687
|
}
|
|
24975
25688
|
function savedRecordIdentity(record3) {
|
|
24976
25689
|
return contentIdentity(recordText(record3));
|
|
@@ -25115,11 +25828,11 @@ function legacyTaskStore(c) {
|
|
|
25115
25828
|
}
|
|
25116
25829
|
|
|
25117
25830
|
// src/history/plans.ts
|
|
25118
|
-
import { createHash as
|
|
25831
|
+
import { createHash as createHash25, randomUUID as randomUUID17 } from "node:crypto";
|
|
25119
25832
|
function assertPlanContent(plan, reference, secrets) {
|
|
25120
25833
|
text(plan, 32768);
|
|
25121
25834
|
const ref = decodeContentRef(reference);
|
|
25122
|
-
if (ref.field !== "plan" || ref.bytes !== Buffer.byteLength(plan) || ref.sha256 !==
|
|
25835
|
+
if (ref.field !== "plan" || ref.bytes !== Buffer.byteLength(plan) || ref.sha256 !== createHash25("sha256").update(plan).digest("hex") || sanitizeText(plan, secrets) !== plan)
|
|
25123
25836
|
throw new ContractError("invalid");
|
|
25124
25837
|
}
|
|
25125
25838
|
function planRecording(plan, graph, operationId, epoch) {
|
|
@@ -26768,7 +27481,7 @@ class HistoryWriter {
|
|
|
26768
27481
|
recordId: randomUUID18(),
|
|
26769
27482
|
version: 1,
|
|
26770
27483
|
bytes: 0,
|
|
26771
|
-
hash:
|
|
27484
|
+
hash: createHash26("sha256"),
|
|
26772
27485
|
parts: 0,
|
|
26773
27486
|
ended: null,
|
|
26774
27487
|
committedSeq: null
|
|
@@ -27146,7 +27859,7 @@ function readOperationStateForPublication(files, operationId) {
|
|
|
27146
27859
|
// src/history/recovery.ts
|
|
27147
27860
|
function digestHistory(files, exclude) {
|
|
27148
27861
|
files.assertFormat();
|
|
27149
|
-
const digest =
|
|
27862
|
+
const digest = createHash27("sha256");
|
|
27150
27863
|
let count2 = 0;
|
|
27151
27864
|
const walk = (path, depth) => {
|
|
27152
27865
|
if (depth > 8 || !files.files.directory(path))
|
|
@@ -27258,7 +27971,7 @@ async function healHistory(lease, log) {
|
|
|
27258
27971
|
|
|
27259
27972
|
// src/subagent-process.ts
|
|
27260
27973
|
import { spawn as spawn5 } from "node:child_process";
|
|
27261
|
-
import { createHash as
|
|
27974
|
+
import { createHash as createHash29, randomUUID as randomUUID22 } from "node:crypto";
|
|
27262
27975
|
import { join as join36 } from "node:path";
|
|
27263
27976
|
import { StringDecoder } from "node:string_decoder";
|
|
27264
27977
|
import { fileURLToPath as fileURLToPath6 } from "node:url";
|
|
@@ -27400,7 +28113,7 @@ class RunEnvironment {
|
|
|
27400
28113
|
}
|
|
27401
28114
|
|
|
27402
28115
|
// src/worker-capture.mjs
|
|
27403
|
-
import { createHash as
|
|
28116
|
+
import { createHash as createHash28, randomUUID as randomUUID21 } from "node:crypto";
|
|
27404
28117
|
var completeCoverage = () => ({
|
|
27405
28118
|
observed: "complete",
|
|
27406
28119
|
source: "complete",
|
|
@@ -27503,7 +28216,7 @@ class CaptureState {
|
|
|
27503
28216
|
final: null,
|
|
27504
28217
|
stopReason: null,
|
|
27505
28218
|
finalIndices: new Set,
|
|
27506
|
-
finalHash:
|
|
28219
|
+
finalHash: createHash28("sha256"),
|
|
27507
28220
|
finalBytes: 0,
|
|
27508
28221
|
finalIndex: -1
|
|
27509
28222
|
});
|
|
@@ -27530,7 +28243,7 @@ class CaptureState {
|
|
|
27530
28243
|
}
|
|
27531
28244
|
this.details.set(e.detailId, {
|
|
27532
28245
|
descriptor: e.descriptor,
|
|
27533
|
-
hash:
|
|
28246
|
+
hash: createHash28("sha256"),
|
|
27534
28247
|
bytes: 0,
|
|
27535
28248
|
ended: false,
|
|
27536
28249
|
preview: ""
|
|
@@ -28591,7 +29304,7 @@ function launchConversation(prepared, conversation, signal, options) {
|
|
|
28591
29304
|
const imageInput = options.images?.length ? JSON.stringify(options.images) : undefined;
|
|
28592
29305
|
const imageDescriptor = imageInput === undefined ? undefined : {
|
|
28593
29306
|
bytes: Buffer.byteLength(imageInput),
|
|
28594
|
-
sha256:
|
|
29307
|
+
sha256: createHash29("sha256").update(imageInput).digest("hex")
|
|
28595
29308
|
};
|
|
28596
29309
|
return prepared.consume((material) => {
|
|
28597
29310
|
encoded2 = encodeEnvelope({
|
|
@@ -30269,7 +30982,7 @@ For follow-up to a settled or interrupted run, inspect retained outcomes first.
|
|
|
30269
30982
|
|
|
30270
30983
|
// src/service/project-knowledge.ts
|
|
30271
30984
|
import { isUtf8 } from "node:buffer";
|
|
30272
|
-
import { createHash as
|
|
30985
|
+
import { createHash as createHash31 } from "node:crypto";
|
|
30273
30986
|
import {
|
|
30274
30987
|
closeSync as closeSync11,
|
|
30275
30988
|
constants as constants11,
|
|
@@ -30287,7 +31000,7 @@ import { dirname as dirname22, posix } from "node:path";
|
|
|
30287
31000
|
|
|
30288
31001
|
// src/service/workflow-git.ts
|
|
30289
31002
|
import { spawn as spawn6, spawnSync as spawnSync6 } from "node:child_process";
|
|
30290
|
-
import { createHash as
|
|
31003
|
+
import { createHash as createHash30 } from "node:crypto";
|
|
30291
31004
|
import {
|
|
30292
31005
|
closeSync as closeSync10,
|
|
30293
31006
|
constants as constants10,
|
|
@@ -30449,7 +31162,7 @@ function fileIdentity(p, st, hashBytes) {
|
|
|
30449
31162
|
try {
|
|
30450
31163
|
if (!fstatSync7(fd).isFile())
|
|
30451
31164
|
throw new ContractError("stale");
|
|
30452
|
-
const digest =
|
|
31165
|
+
const digest = createHash30("sha256"), buffer = Buffer.alloc(CHUNK);
|
|
30453
31166
|
for (let n = readSync6(fd, buffer);n > 0; n = readSync6(fd, buffer))
|
|
30454
31167
|
digest.update(buffer.subarray(0, n));
|
|
30455
31168
|
return `sha256:${digest.digest("hex")}`;
|
|
@@ -30476,7 +31189,7 @@ async function fileIdentityAsync(p, st, hashBytes, signal) {
|
|
|
30476
31189
|
const same2 = (a, b) => a.isFile() && b.isFile() && a.dev === b.dev && a.ino === b.ino && a.size === b.size && a.mtimeMs === b.mtimeMs && a.ctimeMs === b.ctimeMs;
|
|
30477
31190
|
if (!same2(st, before))
|
|
30478
31191
|
throw new ContractError("stale");
|
|
30479
|
-
const digest =
|
|
31192
|
+
const digest = createHash30("sha256"), buffer = Buffer.alloc(CHUNK);
|
|
30480
31193
|
let remaining = before.size;
|
|
30481
31194
|
while (remaining > 0) {
|
|
30482
31195
|
if (signal?.aborted)
|
|
@@ -31217,7 +31930,7 @@ ${line}`;
|
|
|
31217
31930
|
`);
|
|
31218
31931
|
}
|
|
31219
31932
|
var roots = ["engineering", "docs", ".trellis/spec", ".cadence/knowledge"];
|
|
31220
|
-
var digest = (s) =>
|
|
31933
|
+
var digest = (s) => createHash31("sha256").update(s).digest("hex");
|
|
31221
31934
|
var markdown2 = (p) => /\.md$/iu.test(p) && !/^(?:\.cadence\/assistant|\.trellis\/(?:workspace|tasks))(?:\/|$)/u.test(p) && !p.split("/").some((part) => part === ".." || part === ".git" || part === "node_modules" || part.startsWith(".env") || part.startsWith(".") && part !== ".cadence" && part !== ".trellis");
|
|
31222
31935
|
function readKnowledgeFile(root, path) {
|
|
31223
31936
|
if (!markdown2(path))
|
|
@@ -32856,14 +33569,14 @@ import { fileURLToPath as fileURLToPath7 } from "node:url";
|
|
|
32856
33569
|
|
|
32857
33570
|
// src/task-diff.ts
|
|
32858
33571
|
import { spawnSync as spawnSync7 } from "node:child_process";
|
|
32859
|
-
import { createHash as
|
|
33572
|
+
import { createHash as createHash32 } from "node:crypto";
|
|
32860
33573
|
import { lstatSync as lstatSync25, readdirSync as readdirSync5, readlinkSync as readlinkSync2 } from "node:fs";
|
|
32861
33574
|
import { join as join41, relative as relative10 } from "node:path";
|
|
32862
33575
|
var admin = (path) => path === ".cadence/assistant/tasks" || path.startsWith(".cadence/assistant/tasks/");
|
|
32863
33576
|
var GIT_OUTPUT_BYTES = 16 * 1024 * 1024;
|
|
32864
33577
|
function captureChanges(root, outputBytes = GIT_OUTPUT_BYTES) {
|
|
32865
33578
|
const deadline = Date.now() + 3000;
|
|
32866
|
-
const hash3 =
|
|
33579
|
+
const hash3 = createHash32("sha256");
|
|
32867
33580
|
const parts = [];
|
|
32868
33581
|
let complete = true;
|
|
32869
33582
|
const limits = [];
|
|
@@ -32921,7 +33634,7 @@ function captureChanges(root, outputBytes = GIT_OUTPUT_BYTES) {
|
|
|
32921
33634
|
fileBytes += data2.length;
|
|
32922
33635
|
add(name, data2);
|
|
32923
33636
|
const binary = data2.includes(0);
|
|
32924
|
-
parts.push(`${name} (${binary ? "binary" : "text"}, ${data2.length} bytes, sha256 ${
|
|
33637
|
+
parts.push(`${name} (${binary ? "binary" : "text"}, ${data2.length} bytes, sha256 ${createHash32("sha256").update(data2).digest("hex")})`);
|
|
32925
33638
|
} catch {
|
|
32926
33639
|
complete = false;
|
|
32927
33640
|
limits.push(`Unreadable/changing: ${name}`);
|
|
@@ -33097,7 +33810,7 @@ function executionDirectory(execution, tree) {
|
|
|
33097
33810
|
}
|
|
33098
33811
|
|
|
33099
33812
|
// src/service/investigations.ts
|
|
33100
|
-
import { createHash as
|
|
33813
|
+
import { createHash as createHash33 } from "node:crypto";
|
|
33101
33814
|
import { readFileSync as readFileSync7, statSync as statSync4 } from "node:fs";
|
|
33102
33815
|
var INVESTIGATIONS = {
|
|
33103
33816
|
cited: 32,
|
|
@@ -33113,7 +33826,7 @@ function fileDigest(root, path) {
|
|
|
33113
33826
|
const st = statSync4(file);
|
|
33114
33827
|
if (!st.isFile() || st.size > INVESTIGATIONS.fileBytes)
|
|
33115
33828
|
return null;
|
|
33116
|
-
return
|
|
33829
|
+
return createHash33("sha256").update(readFileSync7(file)).digest("hex");
|
|
33117
33830
|
} catch {
|
|
33118
33831
|
return null;
|
|
33119
33832
|
}
|
|
@@ -33141,14 +33854,14 @@ function changedFiles(root, files) {
|
|
|
33141
33854
|
return files.filter((file) => fileDigest(root, file.path) !== file.digest).map((file) => file.path);
|
|
33142
33855
|
}
|
|
33143
33856
|
function questionKey(question, roots2) {
|
|
33144
|
-
return
|
|
33857
|
+
return createHash33("sha256").update(JSON.stringify([
|
|
33145
33858
|
question.trim().replace(/\s+/gu, " "),
|
|
33146
33859
|
[...roots2 ?? []].sort()
|
|
33147
33860
|
])).digest("hex");
|
|
33148
33861
|
}
|
|
33149
33862
|
|
|
33150
33863
|
// src/service/workflow-controller.ts
|
|
33151
|
-
import { createHash as
|
|
33864
|
+
import { createHash as createHash34 } from "node:crypto";
|
|
33152
33865
|
var RECOVERY_BYTES = 32768;
|
|
33153
33866
|
|
|
33154
33867
|
class AttemptFailure extends Error {
|
|
@@ -33457,7 +34170,7 @@ class DeliveryController {
|
|
|
33457
34170
|
this.ports.assertRunning();
|
|
33458
34171
|
if (decision.action === "blocked")
|
|
33459
34172
|
break;
|
|
33460
|
-
const fingerprint2 =
|
|
34173
|
+
const fingerprint2 = createHash34("sha256").update(canonicalJson({
|
|
33461
34174
|
stage,
|
|
33462
34175
|
observation,
|
|
33463
34176
|
failure: attempt2.identity ?? attempt2.message.replace(/[0-9a-f]{8}-[0-9a-f-]{27,}/gu, "<step>"),
|
|
@@ -34404,8 +35117,8 @@ function workflowResultDetail(value, secrets) {
|
|
|
34404
35117
|
var runtimeSummary = (runtime) => `${describeWorkerRuntime(runtime)}
|
|
34405
35118
|
${RUN_ENVIRONMENT_POLICY}`;
|
|
34406
35119
|
var OWNER_RUNTIME = Object.freeze({
|
|
34407
|
-
version: "2.1.
|
|
34408
|
-
build: "
|
|
35120
|
+
version: "2.1.9",
|
|
35121
|
+
build: "90395624f4308e49e37f4c427661bb878871b9d2b80eacff894eb1d897f153c4",
|
|
34409
35122
|
entry: fileURLToPath7(import.meta.url),
|
|
34410
35123
|
pid: process.pid,
|
|
34411
35124
|
node: process.versions.node,
|
|
@@ -37309,7 +38022,7 @@ var processLifetime = {
|
|
|
37309
38022
|
}
|
|
37310
38023
|
};
|
|
37311
38024
|
async function createServiceHost(value, sourceBuild, lifetime) {
|
|
37312
|
-
const embedded = "
|
|
38025
|
+
const embedded = "d70dd3e63843be7df42ff10943fcdc78bcd27b881b0ac8222526e8dad7b0e6e2";
|
|
37313
38026
|
if (embedded && sourceBuild)
|
|
37314
38027
|
throw new ContractError("unsupported-context");
|
|
37315
38028
|
const contractHash = decodeHash(embedded ?? sourceBuild?.contractHash);
|