@opengeni/ogtool 0.3.31-canary.6 → 0.3.31-canary.7

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.
@@ -14328,6 +14328,54 @@ function date4(params) {
14328
14328
 
14329
14329
  // ../../node_modules/.bun/zod@4.4.3/node_modules/zod/v4/classic/external.js
14330
14330
  config(en_default());
14331
+ // ../contracts/src/site-session-http.ts
14332
+ var SITE_WORKSPACE_PREFIX = "/v1/workspaces/site-host";
14333
+
14334
+ class SiteSessionPathError extends Error {
14335
+ code = "site_session_path_unsupported";
14336
+ constructor() {
14337
+ super("Unsupported Site session API path");
14338
+ this.name = "SiteSessionPathError";
14339
+ }
14340
+ }
14341
+ var SITE_SESSION_ROUTES = [
14342
+ { methods: ["GET", "POST"], pattern: /^\/sessions$/u },
14343
+ { methods: ["GET", "PUT"], pattern: /^\/new-session-draft$/u },
14344
+ { methods: ["GET"], pattern: /^\/sessions\/[^/]+$/u },
14345
+ { methods: ["GET"], pattern: /^\/sessions\/[^/]+\/events$/u },
14346
+ { methods: ["GET"], pattern: /^\/sessions\/[^/]+\/events\/stream$/u },
14347
+ { methods: ["POST"], pattern: /^\/sessions\/[^/]+\/events$/u },
14348
+ { methods: ["GET"], pattern: /^\/sessions\/[^/]+\/queue$/u },
14349
+ {
14350
+ methods: ["POST"],
14351
+ pattern: /^\/sessions\/[^/]+\/queue\/[^/]+\/(?:move|edit|steer|delete)$/u
14352
+ },
14353
+ { methods: ["GET", "PUT"], pattern: /^\/sessions\/[^/]+\/composer-draft$/u },
14354
+ { methods: ["POST"], pattern: /^\/sessions\/[^/]+\/composer-draft\/submit$/u }
14355
+ ];
14356
+ function siteSessionRouteAllowed(pathname, method) {
14357
+ if (!pathname.startsWith(SITE_WORKSPACE_PREFIX))
14358
+ return false;
14359
+ const suffix = pathname.slice(SITE_WORKSPACE_PREFIX.length);
14360
+ return SITE_SESSION_ROUTES.some((route) => route.methods.includes(method) && route.pattern.test(suffix));
14361
+ }
14362
+ function siteSessionPath(path, workspaceId, method = "GET", siteId) {
14363
+ const verb = method.toUpperCase();
14364
+ const pathname = path.split("?")[0];
14365
+ const session = siteSessionRouteAllowed(pathname, verb);
14366
+ const context = verb === "GET" && (path === "/v1/config/client" || /^\/v1\/workspaces\/site-host(?:[?].*|$|\/(?:model-catalog|live-events\/stream|control-events(?:\/stream)?|interaction-events\/stream)(?:[?].*|$))/u.test(path));
14367
+ if (!session && !context || /[%\\#]/u.test(pathname) || pathname.split("/").some((p) => p === "." || p === "..")) {
14368
+ throw new SiteSessionPathError;
14369
+ }
14370
+ const rewritten = path.replace("/workspaces/site-host", `/workspaces/${encodeURIComponent(workspaceId)}`);
14371
+ const url2 = new URL(rewritten, "http://site.invalid");
14372
+ if (url2.searchParams.get("originSiteId") === "current" && workspaceId !== "site-host") {
14373
+ url2.searchParams.set("originSiteId", siteId ?? "00000000-0000-0000-0000-000000000000");
14374
+ return url2.pathname + url2.search;
14375
+ }
14376
+ return rewritten;
14377
+ }
14378
+
14331
14379
  // ../contracts/src/tool-catalog.ts
14332
14380
  var ATTEMPT_TOOL_CATALOG_VERSION = 1;
14333
14381
  var TOOL_GATEWAY_CATALOG_VERSION = 1;
@@ -15125,9 +15173,7 @@ class CodemodeClient {
15125
15173
  return CodemodeOperation.parse(await response.json());
15126
15174
  }
15127
15175
  async sessionRequest(path, init) {
15128
- if (!path.startsWith("/v1/")) {
15129
- throw new Error("Unsupported Site session API path");
15130
- }
15176
+ siteSessionPath(path, "site-host", init.method ?? "GET");
15131
15177
  return this.request(`/sdk${path}`, init, false);
15132
15178
  }
15133
15179
  async request(path, init, throwOnError = true) {
@@ -15275,7 +15321,7 @@ async function abortableDelay(delayMs, signal) {
15275
15321
  // package.json
15276
15322
  var package_default = {
15277
15323
  name: "@opengeni/ogtool",
15278
- version: "0.3.31-canary.6",
15324
+ version: "0.3.31-canary.7",
15279
15325
  description: "Codemode CLI and typed client entrypoint for an OpenGeni execution attempt.",
15280
15326
  license: "Apache-2.0",
15281
15327
  repository: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeni/ogtool",
3
- "version": "0.3.31-canary.6",
3
+ "version": "0.3.31-canary.7",
4
4
  "description": "Codemode CLI and typed client entrypoint for an OpenGeni execution attempt.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -37,7 +37,7 @@
37
37
  "prepublishOnly": "bash ../../scripts/prepublish-guard"
38
38
  },
39
39
  "dependencies": {
40
- "@opengeni/codemode": "^0.4.27-canary.6"
40
+ "@opengeni/codemode": "^0.4.27-canary.7"
41
41
  },
42
42
  "engines": {
43
43
  "node": ">=18"