@automagik/omni 2.260717.4 → 2.260717.6

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/index.js CHANGED
@@ -125164,7 +125164,7 @@ import { fileURLToPath } from "url";
125164
125164
  // package.json
125165
125165
  var package_default = {
125166
125166
  name: "@automagik/omni",
125167
- version: "2.260717.4",
125167
+ version: "2.260717.6",
125168
125168
  description: "LLM-optimized CLI for Omni",
125169
125169
  type: "module",
125170
125170
  bin: {
@@ -225883,7 +225883,7 @@ var init_sentry_scrub = __esm(() => {
225883
225883
  var require_package7 = __commonJS((exports, module) => {
225884
225884
  module.exports = {
225885
225885
  name: "@omni/api",
225886
- version: "2.260717.4",
225886
+ version: "2.260717.6",
225887
225887
  type: "module",
225888
225888
  exports: {
225889
225889
  ".": {
@@ -284984,16 +284984,26 @@ var init_genie_signature = __esm(() => {
284984
284984
  log59 = createLogger("api:genie-signature");
284985
284985
  ED25519_SPKI_PREFIX = Buffer.from("302a300506032b6570032100", "hex");
284986
284986
  genieSignatureMiddleware = createMiddleware(async (c, next) => {
284987
- const services = c.get("services");
284988
- if (!services?.genieHosts) {
284989
- return next();
284990
- }
284991
284987
  const hostIdHeader = c.req.header(HEADER_HOST_ID);
284992
284988
  const timestampHeader = c.req.header(HEADER_TIMESTAMP);
284993
284989
  const signatureHeader = c.req.header(HEADER_SIGNATURE);
284994
284990
  if (!hostIdHeader && !timestampHeader && !signatureHeader) {
284995
284991
  return next();
284996
284992
  }
284993
+ const services = c.get("services");
284994
+ if (!services?.genieHosts) {
284995
+ log59.warn("genie signature verification service unavailable", {
284996
+ hostId: hostIdHeader,
284997
+ method: c.req.method,
284998
+ path: new URL(c.req.url).pathname
284999
+ });
285000
+ return c.json({
285001
+ error: {
285002
+ code: "GENIE_SIGNATURE_SERVICE_UNAVAILABLE",
285003
+ message: "Genie host signature verification is temporarily unavailable."
285004
+ }
285005
+ }, 503);
285006
+ }
284997
285007
  let body = "";
284998
285008
  if (c.req.method !== "GET" && c.req.method !== "HEAD") {
284999
285009
  body = await c.req.text();
@@ -285684,16 +285694,27 @@ var init_scopes = __esm(() => {
285684
285694
  });
285685
285695
 
285686
285696
  // ../api/src/lib/signed-host-scope-context.ts
285697
+ function hasAnyGenieSignatureHeader(c) {
285698
+ return GENIE_SIGNATURE_HEADERS.some((header) => c.req.header(header) !== undefined);
285699
+ }
285687
285700
  function readSignedHostScopeContext(c) {
285688
285701
  const hostId = c.get("signedBy");
285689
- if (!hostId)
285702
+ if (!hostId) {
285703
+ if (hasAnyGenieSignatureHeader(c)) {
285704
+ return { kind: "invalid", hostId: c.req.header("x-genie-host-id") ?? "unknown" };
285705
+ }
285690
285706
  return { kind: "unsigned" };
285707
+ }
285691
285708
  const scopes = c.get("signedByScopes");
285692
285709
  if (!Array.isArray(scopes) || !scopes.every((scope) => typeof scope === "string")) {
285693
285710
  return { kind: "invalid", hostId };
285694
285711
  }
285695
285712
  return { kind: "valid", hostId, scopes };
285696
285713
  }
285714
+ var GENIE_SIGNATURE_HEADERS;
285715
+ var init_signed_host_scope_context = __esm(() => {
285716
+ GENIE_SIGNATURE_HEADERS = ["x-genie-host-id", "x-genie-timestamp", "x-genie-signature"];
285717
+ });
285697
285718
 
285698
285719
  // ../api/src/middleware/scope-enforcer.ts
285699
285720
  function buildSegmentRegex(patternPath) {
@@ -285878,6 +285899,7 @@ var init_scope_enforcer = __esm(() => {
285878
285899
  init_factory2();
285879
285900
  init_profiles();
285880
285901
  init_scopes();
285902
+ init_signed_host_scope_context();
285881
285903
  init_api_keys();
285882
285904
  log61 = createLogger("api:scope-enforcer");
285883
285905
  OUTBOUND_SEND_PREFIXES = ["/messages/send"];
@@ -356823,6 +356845,20 @@ function enforceScopeCeiling(c, requestedScopes) {
356823
356845
  }
356824
356846
  }, 403);
356825
356847
  }
356848
+ function enforceInstanceCeiling(c, requestedInstanceIds) {
356849
+ const apiKey = c.get("apiKey");
356850
+ if (apiKey?.instanceIds === null)
356851
+ return null;
356852
+ const exceedsCaller = !apiKey || !Array.isArray(apiKey.instanceIds) || requestedInstanceIds === null || requestedInstanceIds.some((instanceId) => !apiKey.instanceIds?.includes(instanceId));
356853
+ if (!exceedsCaller)
356854
+ return null;
356855
+ return c.json({
356856
+ error: {
356857
+ code: "FORBIDDEN",
356858
+ message: "Cannot grant instance access that exceeds the caller's own."
356859
+ }
356860
+ }, 403);
356861
+ }
356826
356862
  async function handleProfileCreate(c, data, services) {
356827
356863
  try {
356828
356864
  const resolved = resolveProfile({
@@ -356837,6 +356873,9 @@ async function handleProfileCreate(c, data, services) {
356837
356873
  const ceilingDenied = enforceScopeCeiling(c, resolved.scopes);
356838
356874
  if (ceilingDenied)
356839
356875
  return ceilingDenied;
356876
+ const instanceCeilingDenied = enforceInstanceCeiling(c, data.instanceIds ?? null);
356877
+ if (instanceCeilingDenied)
356878
+ return instanceCeilingDenied;
356840
356879
  const result = await services.apiKeys.create({
356841
356880
  name: data.name,
356842
356881
  description: data.description,
@@ -356872,6 +356911,9 @@ async function handleLegacyCreate(c, data, services) {
356872
356911
  const ceilingDenied = enforceScopeCeiling(c, data.scopes);
356873
356912
  if (ceilingDenied)
356874
356913
  return ceilingDenied;
356914
+ const instanceCeilingDenied = enforceInstanceCeiling(c, data.instanceIds ?? null);
356915
+ if (instanceCeilingDenied)
356916
+ return instanceCeilingDenied;
356875
356917
  const result = await services.apiKeys.create({
356876
356918
  name: data.name,
356877
356919
  description: data.description,
@@ -356889,6 +356931,7 @@ var init_keys = __esm(() => {
356889
356931
  init_dist2();
356890
356932
  init_zod();
356891
356933
  init_resolve_profile();
356934
+ init_signed_host_scope_context();
356892
356935
  init_date_query();
356893
356936
  init_api_keys();
356894
356937
  keysRoutes = new Hono2;
@@ -356998,6 +357041,11 @@ var init_keys = __esm(() => {
356998
357041
  if (ceilingDenied)
356999
357042
  return ceilingDenied;
357000
357043
  }
357044
+ if (data.instanceIds !== undefined) {
357045
+ const instanceCeilingDenied = enforceInstanceCeiling(c, data.instanceIds);
357046
+ if (instanceCeilingDenied)
357047
+ return instanceCeilingDenied;
357048
+ }
357001
357049
  try {
357002
357050
  const updated = await services.apiKeys.update(id, {
357003
357051
  ...data,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automagik/omni",
3
- "version": "2.260717.4",
3
+ "version": "2.260717.6",
4
4
  "description": "LLM-optimized CLI for Omni",
5
5
  "type": "module",
6
6
  "bin": {