@opengeni/api-router 2.13.0-canary.0 → 2.13.0-canary.1

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/app.js CHANGED
@@ -24,7 +24,7 @@ import {
24
24
  withDefaultEnabledCapabilityMcpTools,
25
25
  workflowIdForSession,
26
26
  workspaceActorContextExempt
27
- } from "./chunk-BJWHVMOL.js";
27
+ } from "./chunk-V4IDX7VJ.js";
28
28
  export {
29
29
  API_MAX_REQUEST_BODY_BYTES,
30
30
  allowedCorsOrigin,
@@ -156,6 +156,7 @@ function feedbackHttpError(error) {
156
156
  }
157
157
 
158
158
  // src/codemode.ts
159
+ import { siteRequestHeaders } from "@opengeni/contracts/site-session-http";
159
160
  import {
160
161
  codemodeDispatchSubject,
161
162
  decodeCodemodeDispatchAck,
@@ -476,14 +477,9 @@ async function codemodeSessionRequest(deps, grant, request, path) {
476
477
  const target = new URL(request.url);
477
478
  const rewritten = siteSessionPath(path, authority.workspaceId, request.method);
478
479
  const url = new URL(rewritten, target.origin);
479
- const headers = new Headers({
480
- authorization: `Bearer ${token}`,
481
- [OPENGENI_API_CONTRACT_HEADER]: OPENGENI_API_CONTRACT_REVISION
482
- });
483
- for (const name of ["content-type", "accept", "last-event-id"]) {
484
- const value = request.headers.get(name);
485
- if (value) headers.set(name, value);
486
- }
480
+ const headers = siteRequestHeaders(request.headers);
481
+ headers.set("authorization", `Bearer ${token}`);
482
+ headers.set(OPENGENI_API_CONTRACT_HEADER, OPENGENI_API_CONTRACT_REVISION);
487
483
  return new Request(url, {
488
484
  method: request.method,
489
485
  headers,
@@ -6143,8 +6139,8 @@ import {
6143
6139
  upsertSessionGoalWithEvent,
6144
6140
  RigChangeTransitionError,
6145
6141
  createWorkspaceArtifact,
6146
- getWorkspaceArtifact as getWorkspaceArtifact3,
6147
- getWorkspaceArtifactContentRef,
6142
+ getWorkspaceArtifact as getWorkspaceArtifact2,
6143
+ getWorkspaceArtifactContentRef as getWorkspaceArtifactContentRef2,
6148
6144
  listWorkspaceArtifacts,
6149
6145
  publishWorkspaceArtifactVersion,
6150
6146
  rollbackWorkspaceArtifact,
@@ -7980,7 +7976,7 @@ import {
7980
7976
  requireWorkspace,
7981
7977
  withCodexAppsRequestAuthorization,
7982
7978
  consumeToolGatewayApproval,
7983
- getWorkspaceArtifact,
7979
+ getWorkspaceArtifactContentRef,
7984
7980
  issueToolGatewayApproval,
7985
7981
  ToolGatewayApprovalOperationStartedError,
7986
7982
  ToolGatewayApprovalRateLimitError,
@@ -9016,14 +9012,18 @@ function throwWorkspaceToolGatewayHttpError(error) {
9016
9012
  }
9017
9013
  throw error;
9018
9014
  }
9019
- async function requireWorkspaceSiteToolAuthorization(db, grant, context) {
9015
+ async function requireWorkspaceSiteToolAuthorization(db, grant, context, resolveVersion = getWorkspaceArtifactContentRef) {
9020
9016
  try {
9021
- const detail = await getWorkspaceArtifact(db, grant.workspaceId, context.siteArtifactId);
9022
- const currentVersion = detail.artifact.currentVersion;
9023
- const requested = currentVersion?.requestedTools.some(
9017
+ const { status, version: version2 } = await resolveVersion(
9018
+ db,
9019
+ grant.workspaceId,
9020
+ context.siteArtifactId,
9021
+ context.siteVersionId
9022
+ );
9023
+ const requested = version2.requestedTools.some(
9024
9024
  (identity) => identity.serverId === context.identity.serverId && identity.toolName === context.identity.toolName
9025
9025
  );
9026
- if (detail.artifact.status !== "active" || currentVersion?.id !== context.siteVersionId || !requested) {
9026
+ if (status !== "active" || version2.id !== context.siteVersionId || !requested) {
9027
9027
  throw new HTTPException8(403, { message: "site_tool_not_authorized" });
9028
9028
  }
9029
9029
  } catch (error) {
@@ -9816,7 +9816,7 @@ function registerFileRoutes(app, deps) {
9816
9816
  const workspaceId = c.req.param("workspaceId");
9817
9817
  const grant = await requireAccessGrant5(c, deps, workspaceId, "files:read");
9818
9818
  const artifactId2 = retainedArtifactId(c.req.param("artifactId"));
9819
- const artifact = await getWorkspaceArtifact2(db, {
9819
+ const artifact = await getWorkspaceArtifact(db, {
9820
9820
  accountId: grant.accountId,
9821
9821
  workspaceId,
9822
9822
  subjectId: await fileAuthoritySubjectIdForGrant(deps, grant),
@@ -9831,7 +9831,7 @@ function registerFileRoutes(app, deps) {
9831
9831
  const workspaceId = c.req.param("workspaceId");
9832
9832
  const grant = await requireAccessGrant5(c, deps, workspaceId, "files:read");
9833
9833
  const artifactId2 = retainedArtifactId(c.req.param("artifactId"));
9834
- const artifact = await getWorkspaceArtifact2(db, {
9834
+ const artifact = await getWorkspaceArtifact(db, {
9835
9835
  accountId: grant.accountId,
9836
9836
  workspaceId,
9837
9837
  subjectId: await fileAuthoritySubjectIdForGrant(deps, grant),
@@ -10116,7 +10116,7 @@ function retainedArtifactMetadata(artifact) {
10116
10116
  }
10117
10117
  return retainedArtifactUnavailable(file.id, "unsupported");
10118
10118
  }
10119
- async function getWorkspaceArtifact2(db, input) {
10119
+ async function getWorkspaceArtifact(db, input) {
10120
10120
  const generated = await getGeneratedImageArtifact(db, input.workspaceId, input.artifactId);
10121
10121
  if (generated) {
10122
10122
  return { file: generated.file, metadata: retainedGeneratedImageMetadata(generated) };
@@ -27187,8 +27187,8 @@ function registerWorkspaceArtifactTools(server, deps, grant, sessionId, json) {
27187
27187
  await authorize();
27188
27188
  if (!deps.objectStorage) throw new Error("Object storage is not configured");
27189
27189
  const [rawDetail, ref] = await Promise.all([
27190
- getWorkspaceArtifact3(deps.db, grant.workspaceId, artifactId2),
27191
- getWorkspaceArtifactContentRef(deps.db, grant.workspaceId, artifactId2, versionId)
27190
+ getWorkspaceArtifact2(deps.db, grant.workspaceId, artifactId2),
27191
+ getWorkspaceArtifactContentRef2(deps.db, grant.workspaceId, artifactId2, versionId)
27192
27192
  ]);
27193
27193
  const sourceAuthorizations = /* @__PURE__ */ new Map();
27194
27194
  const canReadSourceSession = (sourceSessionId) => {
@@ -94108,8 +94108,8 @@ import {
94108
94108
  } from "@opengeni/core";
94109
94109
  import {
94110
94110
  createWorkspaceArtifact as createWorkspaceArtifact2,
94111
- getWorkspaceArtifact as getWorkspaceArtifact4,
94112
- getWorkspaceArtifactContentRef as getWorkspaceArtifactContentRef2,
94111
+ getWorkspaceArtifact as getWorkspaceArtifact3,
94112
+ getWorkspaceArtifactContentRef as getWorkspaceArtifactContentRef3,
94113
94113
  listWorkspaceArtifacts as listWorkspaceArtifacts2,
94114
94114
  nestedPostgresSqlState as nestedPostgresSqlState6,
94115
94115
  publishWorkspaceArtifactVersion as publishWorkspaceArtifactVersion2,
@@ -94231,7 +94231,7 @@ function registerWorkspaceArtifactRoutes(app, deps) {
94231
94231
  throw new HTTPException81(503, {
94232
94232
  message: "Object storage is not configured"
94233
94233
  });
94234
- const ref = await getWorkspaceArtifactContentRef2(
94234
+ const ref = await getWorkspaceArtifactContentRef3(
94235
94235
  deps.db,
94236
94236
  workspaceId,
94237
94237
  artifactId(context),
@@ -94315,7 +94315,7 @@ function registerWorkspaceArtifactRoutes(app, deps) {
94315
94315
  const workspaceId = context.req.param("workspaceId");
94316
94316
  const grant = await requireAccessGrant42(context, deps, workspaceId, "artifacts:read");
94317
94317
  try {
94318
- const detail = await getWorkspaceArtifact4(deps.db, workspaceId, artifactId(context));
94318
+ const detail = await getWorkspaceArtifact3(deps.db, workspaceId, artifactId(context));
94319
94319
  return context.json(
94320
94320
  WorkspaceArtifactDetailResponse.parse(
94321
94321
  await projectWorkspaceArtifactDetailProvenance(
@@ -94335,7 +94335,7 @@ function registerWorkspaceArtifactRoutes(app, deps) {
94335
94335
  throw new HTTPException81(503, {
94336
94336
  message: "Object storage is not configured"
94337
94337
  });
94338
- const ref = await getWorkspaceArtifactContentRef2(
94338
+ const ref = await getWorkspaceArtifactContentRef3(
94339
94339
  deps.db,
94340
94340
  workspaceId,
94341
94341
  artifactId(context),
@@ -94375,7 +94375,7 @@ function registerWorkspaceArtifactRoutes(app, deps) {
94375
94375
  });
94376
94376
  const parsedVersion = parseVersionId(context.req.query("versionId"));
94377
94377
  try {
94378
- const ref = await getWorkspaceArtifactContentRef2(
94378
+ const ref = await getWorkspaceArtifactContentRef3(
94379
94379
  deps.db,
94380
94380
  workspaceId,
94381
94381
  artifactId(context),
@@ -105876,4 +105876,4 @@ export {
105876
105876
  withDefaultEnabledCapabilityMcpTools,
105877
105877
  workflowIdForSession4 as workflowIdForSession
105878
105878
  };
105879
- //# sourceMappingURL=chunk-BJWHVMOL.js.map
105879
+ //# sourceMappingURL=chunk-V4IDX7VJ.js.map