shiplightai 0.1.83 → 0.1.85
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/cjs/debugger-manager.cjs +6 -6
- package/dist/cjs/debugger-pw.cjs +49 -49
- package/dist/cjs/debugger-server.cjs +2 -2
- package/dist/cjs/fixture.cjs +66 -66
- package/dist/cjs/index.cjs +62 -62
- package/dist/cjs/reporter.cjs +46 -46
- package/dist/cli.js +93 -88
- package/dist/debugger-manager.js +4 -4
- package/dist/debugger-pw.js +44 -44
- package/dist/debugger-server.js +2 -2
- package/dist/fixture.d.ts +22 -4
- package/dist/fixture.js +66 -66
- package/dist/index.d.ts +6 -18
- package/dist/index.js +58 -58
- package/dist/reporter.js +42 -42
- package/dist/static-embedded/assets/{index-kLbqwQLo.js → index-Bcj9zYt-.js} +258 -157
- package/dist/static-embedded/assets/{index-C_mtQZuo.js → index-CMdPZNG2.js} +2 -2
- package/dist/static-embedded/index.html +1 -1
- package/package.json +1 -1
package/dist/debugger-server.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{Router as
|
|
1
|
+
import{Router as H}from"express";import P from"express";import*as m from"fs";import*as d from"path";import{Router as D}from"express";var x="shp_",R="https://nova-api.shiplight.ai",j="https://api.shiplight.ai";function A(e){return e.startsWith(x)}function I(e,t){let o=t?.trim();return o?$(o):A(e)?R:j}function $(e){return e.endsWith("/")?e.slice(0,-1):e}function S(){let e=D();return e.get("/api/email-forwarding/addresses",async(t,o)=>{let c=process.env.SHIPLIGHT_API_TOKEN;if(!c){console.error("[email-forwarding] SHIPLIGHT_API_TOKEN not set, skipping"),o.json({addresses:[],configured:!1});return}let f=I(c,process.env.SHIPLIGHT_API_URL),p=`${f}/email-forwarding/addresses`;try{let a=await fetch(p,{headers:{Authorization:`Bearer ${c}`},signal:AbortSignal.timeout(1e4)});if(!a.ok){let b=(await a.json().catch(()=>({}))).error??`${a.status} ${a.statusText}`;console.error(`[email-forwarding] upstream ${a.status}: ${b}`),o.status(a.status).json({error:b});return}let r=await a.json();o.json({...r,configured:!0})}catch(a){let r=a instanceof Error?a.message:String(a);console.error(`[email-forwarding] fetch error: ${r}`),o.status(502).json({error:`Failed to reach Shiplight API (${f}): ${r}`})}}),e}function _(e){return e?d.isAbsolute(e)?d.normalize(e):d.resolve(e):null}function U(e,t){let o=t.headers.host??"127.0.0.1";return`${(t.headers["x-forwarded-proto"]??"ws")==="https"?"wss":"ws"}://${o}/ws/debugger/${e}/cdp-browser`}function T(e){let t=d.basename(e);return t.endsWith(".test.yaml")||t.endsWith(".test.yml")}function B(e){let{manager:t,staticDir:o,resolveYamlPath:c=_,liveviewUrlBuilder:f=U,fallbackRouter:p,artifactsDir:a}=e,r=H(),y=a?P.static(a):null;r.post("/api/debugger/sessions",P.json(),async(n,s)=>{let i=n.body?.yamlPath;if(typeof i!="string"||!i){s.status(400).json({error:"yamlPath is required"});return}let u=c(i);if(!u){s.status(403).json({error:"Path outside allowed roots"});return}if(!T(u)){s.status(400).json({error:"Not a Shiplight test file (expected *.test.yaml or *.test.yml)"});return}if(!m.existsSync(u)){s.status(404).json({error:"File not found"});return}let g=t.listSessions().find(l=>l.yamlPath===u&&l.status!=="ended");try{let l=t.openSession(u);s.status(g?200:201).json({sessionId:l.sessionId,yamlPath:l.yamlPath,startedAt:l.startedAt,status:l.status})}catch(l){s.status(500).json({error:l.message})}}),r.get("/api/debugger/sessions",(n,s)=>{s.setHeader("Cache-Control","no-store"),s.json({sessions:t.listSessions().map(i=>({sessionId:i.sessionId,yamlPath:i.yamlPath,startedAt:i.startedAt,status:i.status}))})}),r.delete("/api/debugger/sessions/:sessionId",async(n,s)=>{let i=n.params.sessionId,u=!!t.getSession(i);await t.closeSession(i),s.json({deleted:!0,alreadyGone:!u})}),m.existsSync(o)?r.use("/debugger/static",P.static(o)):console.error(`[debugger] WARNING: debugger static dir missing at ${o} \u2014 iframe routes will 404`),r.get("/debugger/:sessionId/",(n,s)=>{let i=n.params.sessionId;if(!t.getSession(i)){s.status(404).send("Debugger session not found");return}let g=d.join(o,"index.html");if(!m.existsSync(g)){s.status(500).send(`Debugger SPA bundle missing at ${g}`);return}let w=m.readFileSync(g,"utf-8").replace(/(src|href)="\/assets\//g,'$1="/debugger/static/assets/').replace(/(src|href)="\/index\.html/g,'$1="/debugger/static/index.html');s.type("html").send(w)}),r.use("/debugger/:sessionId",S());let b=async(n,s,i)=>{let u=n.params.sessionId;if(u==="static")return i();let g=t.getSession(u);if(!g){s.status(404).json({status:"error",message:"Session not found"});return}let l=n.originalUrl,w=`/debugger/${u}`;if(l.startsWith(w)){let h=l.slice(w.length)||"/";n.url=h,Object.defineProperty(n,"originalUrl",{value:h,configurable:!0})}if(y&&n.path.startsWith("/api/report-assets/")){n.url=n.url.replace(/^\/api\/report-assets/,""),y(n,s,i);return}if(g.status==="idle"||g.status==="starting"){let h=`${n.method} ${n.path}`;if(h==="POST /api/int-runner/create-session")try{await t.startSandbox(u)}catch(v){s.status(500).json({status:"error",message:v.message});return}else if(h==="POST /api/int-runner/liveview-url"){s.json({liveviewUrl:"",browserWsUrl:""});return}else if(n.path.startsWith("/api/int-runner/")){s.status(503).json({status:"error",message:"Sandbox not started"});return}else if(p){p(n,s,i);return}else{s.status(503).json({status:"error",message:"Sandbox not started"});return}}t.httpProxyFor(u,{liveviewUrlBuilder:()=>f(u,n)})(n,s,i)};return r.use("/debugger/:sessionId",b),r}function F(e,t,o,c){let p=(t.url??"").match(/^\/ws\/debugger\/([^/]+)(.*)$/);if(!p){o.write(`HTTP/1.1 404 Not Found\r
|
|
2
2
|
\r
|
|
3
|
-
`),
|
|
3
|
+
`),o.destroy();return}let a=p[1],r=p[2]||"";r.startsWith("/cdp-browser/page/")?r=r.slice(12):(r==="/cdp-browser"||r==="/cdp-browser/")&&(r=""),e.wsUpgradeFor(a)(t,o,c,r||void 0)}export{B as createDebuggerHttpRoutes,F as handleDebuggerUpgrade};
|
package/dist/fixture.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _playwright_test from '@playwright/test';
|
|
2
|
-
import { Browser } from '@playwright/test';
|
|
2
|
+
import { Browser, TestInfo } from '@playwright/test';
|
|
3
3
|
export { expect } from '@playwright/test';
|
|
4
4
|
import { VariableStore } from './VariableStore.js';
|
|
5
5
|
import { WebAgent } from './agent/webAgent.js';
|
|
@@ -9,7 +9,8 @@ import './config.js';
|
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Per-test auth: path to a login script + optional args passed to the login function.
|
|
12
|
-
*
|
|
12
|
+
* A relative auth path is resolved against the Playwright project root (config.rootDir),
|
|
13
|
+
* not process.cwd() — see resolveProjectRoot for why the two can diverge.
|
|
13
14
|
* The login module must export a login(args, browser?) function that performs the
|
|
14
15
|
* login flow, caches the storageState, and returns the file path. The fixture passes
|
|
15
16
|
* its shared browser instance — the login function must NOT close it, only its context.
|
|
@@ -24,6 +25,23 @@ interface AuthSpec {
|
|
|
24
25
|
auth: string;
|
|
25
26
|
args?: Record<string, unknown>;
|
|
26
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* Resolve the project root used to anchor relative file paths in tests — most
|
|
30
|
+
* notably the `upload_file` action's `paths`, which the SDK joins against the
|
|
31
|
+
* agent context's `testDataDir` (falling back to `process.cwd()` when unset).
|
|
32
|
+
*
|
|
33
|
+
* Playwright does NOT chdir to the project root: `process.cwd()` is the directory
|
|
34
|
+
* the test command was invoked from, which is not guaranteed to equal the project
|
|
35
|
+
* root. It diverges whenever the run is launched from elsewhere — e.g.
|
|
36
|
+
* `playwright test --config sub/playwright.config.ts` from a parent dir, or a
|
|
37
|
+
* monorepo invocation pointing at a sub-package config. Anchoring uploads to
|
|
38
|
+
* `process.cwd()` breaks in exactly those cases.
|
|
39
|
+
*
|
|
40
|
+
* `testInfo.config.rootDir` is Playwright's own anchor — the directory of the
|
|
41
|
+
* resolved config file — so it tracks the project root regardless of cwd. Fall
|
|
42
|
+
* back to `process.cwd()` only if rootDir is somehow unavailable.
|
|
43
|
+
*/
|
|
44
|
+
declare function resolveProjectRoot(testInfo: Pick<TestInfo, 'config'>): string;
|
|
27
45
|
/**
|
|
28
46
|
* Calls the auth module's login(args, browser) function.
|
|
29
47
|
* The login function is responsible for performing the login flow,
|
|
@@ -36,7 +54,7 @@ interface AuthSpec {
|
|
|
36
54
|
* The module is cached by Node's module system after the first import,
|
|
37
55
|
* so multiple tests sharing the same auth path reuse the same instance.
|
|
38
56
|
*/
|
|
39
|
-
declare function resolveAuthState(spec: AuthSpec, browser?: Browser, baseURL?: string): Promise<string>;
|
|
57
|
+
declare function resolveAuthState(spec: AuthSpec, browser?: Browser, baseURL?: string, projectRoot?: string): Promise<string>;
|
|
40
58
|
/**
|
|
41
59
|
* Standard Playwright context-option `use:` keys whose resolved (per-test aware)
|
|
42
60
|
* values we overlay onto `testInfo.project.use`. Must stay identical to the
|
|
@@ -193,4 +211,4 @@ type ShiplightFixtures = {
|
|
|
193
211
|
};
|
|
194
212
|
declare const test: _playwright_test.TestType<_playwright_test.PlaywrightTestArgs & _playwright_test.PlaywrightTestOptions & ShiplightFixtures, _playwright_test.PlaywrightWorkerArgs & _playwright_test.PlaywrightWorkerOptions>;
|
|
195
213
|
|
|
196
|
-
export { type AuthSpec, EXCLUDED_CONTEXT_OPTION_KEYS, HANDLED_CONTEXT_OPTION_KEYS, SDK_ENV_ALLOWLIST, type TestContext, VIEWPORT_INCOMPATIBLE_OPTIONS, applyVarsOverride, buildSdkEnv, createTestContext, dropViewportIncompatibleOptions, isDeclaredSensitive, mergeResolvedContextOptions, parseVarsOverrideEnv, resolveAuthState, test };
|
|
214
|
+
export { type AuthSpec, EXCLUDED_CONTEXT_OPTION_KEYS, HANDLED_CONTEXT_OPTION_KEYS, SDK_ENV_ALLOWLIST, type TestContext, VIEWPORT_INCOMPATIBLE_OPTIONS, applyVarsOverride, buildSdkEnv, createTestContext, dropViewportIncompatibleOptions, isDeclaredSensitive, mergeResolvedContextOptions, parseVarsOverrideEnv, resolveAuthState, resolveProjectRoot, test };
|