@slicemachine/manager 0.25.7-alpha.jp-figma-to-prismic.4 → 0.25.7-alpha.jp-figma-to-prismic.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.
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  const _commonjsHelpers = require("../../_virtual/_commonjsHelpers.cjs");
3
- const index = require("../../_virtual/index5.cjs");
3
+ const index = require("../../_virtual/index4.cjs");
4
4
  const require$$0 = require("buffer");
5
5
  const require$$0$1 = require("stream");
6
6
  const require$$2 = require("util");
@@ -1,5 +1,5 @@
1
1
  import { getDefaultExportFromCjs } from "../../_virtual/_commonjsHelpers.js";
2
- import { __module as getStream$2 } from "../../_virtual/index5.js";
2
+ import { __module as getStream$2 } from "../../_virtual/index4.js";
3
3
  import require$$0 from "buffer";
4
4
  import require$$0$1 from "stream";
5
5
  import require$$2 from "util";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  const _commonjsHelpers = require("../../_virtual/_commonjsHelpers.cjs");
3
- const index = require("../../_virtual/index4.cjs");
3
+ const index = require("../../_virtual/index5.cjs");
4
4
  const require$$0 = require("assert");
5
5
  const signals$1 = require("./signals.cjs");
6
6
  const require$$2 = require("events");
@@ -1,5 +1,5 @@
1
1
  import { getDefaultExportFromCjs, commonjsGlobal } from "../../_virtual/_commonjsHelpers.js";
2
- import { __module as signalExit } from "../../_virtual/index4.js";
2
+ import { __module as signalExit } from "../../_virtual/index5.js";
3
3
  import require$$0 from "assert";
4
4
  import { __require as requireSignals } from "./signals.js";
5
5
  import require$$2 from "events";
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- var signalExit = { exports: {} };
4
- exports.__module = signalExit;
3
+ var getStream = { exports: {} };
4
+ exports.__module = getStream;
5
5
  //# sourceMappingURL=index4.cjs.map
@@ -1,5 +1,5 @@
1
- var signalExit = { exports: {} };
1
+ var getStream = { exports: {} };
2
2
  export {
3
- signalExit as __module
3
+ getStream as __module
4
4
  };
5
5
  //# sourceMappingURL=index4.js.map
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- var getStream = { exports: {} };
4
- exports.__module = getStream;
3
+ var signalExit = { exports: {} };
4
+ exports.__module = signalExit;
5
5
  //# sourceMappingURL=index5.cjs.map
@@ -1,5 +1,5 @@
1
- var getStream = { exports: {} };
1
+ var signalExit = { exports: {} };
2
2
  export {
3
- getStream as __module
3
+ signalExit as __module
4
4
  };
5
5
  //# sourceMappingURL=index5.js.map
@@ -16,8 +16,7 @@ const API_ENDPOINTS = (() => {
16
16
  SliceMachineV1: trailingSlash.addTrailingSlash(process.env.slice_machine_v1_endpoint ?? "https://sm-api.wroom.io/v1/"),
17
17
  RepositoryService: trailingSlash.addTrailingSlash(process.env.repository_api ?? "https://api.internal.wroom.io/repository/"),
18
18
  LocaleService: trailingSlash.addTrailingSlash(process.env.locale_api ?? "https://api.internal.wroom.io/locale/"),
19
- CustomTypeService: trailingSlash.addTrailingSlash(process.env.custom_type_api ?? "https://api.internal.wroom.io/custom-type/"),
20
- LlmProxyTypeService: trailingSlash.addTrailingSlash(process.env.llm_proxy_api ?? "https://sbqznqszdlqhjn4p4nfhtst6ra0wngjc.lambda-url.us-east-1.on.aws/")
19
+ CustomTypeService: trailingSlash.addTrailingSlash(process.env.custom_type_api ?? "https://api.internal.wroom.io/custom-type/")
21
20
  };
22
21
  const missingAPIEndpoints = Object.keys(apiEndpoints).filter((key) => {
23
22
  return !apiEndpoints[key];
@@ -52,8 +51,7 @@ If you didn't intend to run Slice Machine this way, stop it immediately and unse
52
51
  SliceMachineV1: "https://sm-api.wroom.io/v1/",
53
52
  RepositoryService: "https://api.internal.wroom.io/repository/",
54
53
  LocaleService: "https://api.internal.wroom.io/locale/",
55
- CustomTypeService: "https://api.internal.wroom.io/custom-type/",
56
- LlmProxyTypeService: "https://sbqznqszdlqhjn4p4nfhtst6ra0wngjc.lambda-url.us-east-1.on.aws/"
54
+ CustomTypeService: "https://api.internal.wroom.io/custom-type/"
57
55
  };
58
56
  }
59
57
  case APPLICATION_MODE.APPLICATION_MODE.DevTools:
@@ -70,8 +68,7 @@ If you didn't intend to run Slice Machine this way, stop it immediately and unse
70
68
  SliceMachineV1: `https://sm-api.${process.env.SM_ENV}-wroom.com/v1/`,
71
69
  RepositoryService: `https://api.internal.${process.env.SM_ENV}-wroom.com/repository/`,
72
70
  LocaleService: `https://api.internal.${process.env.SM_ENV}-wroom.com/locale/`,
73
- CustomTypeService: `https://api.internal.${process.env.SM_ENV}-wroom.com/custom-type/`,
74
- LlmProxyTypeService: "https://sbqznqszdlqhjn4p4nfhtst6ra0wngjc.lambda-url.us-east-1.on.aws/"
71
+ CustomTypeService: `https://api.internal.${process.env.SM_ENV}-wroom.com/custom-type/`
75
72
  };
76
73
  }
77
74
  case APPLICATION_MODE.APPLICATION_MODE.Production:
@@ -87,8 +84,7 @@ If you didn't intend to run Slice Machine this way, stop it immediately and unse
87
84
  SliceMachineV1: "https://sm-api.prismic.io/v1/",
88
85
  RepositoryService: "https://api.internal.prismic.io/repository/",
89
86
  LocaleService: "https://api.internal.prismic.io/locale/",
90
- CustomTypeService: "https://api.internal.prismic.io/custom-type/",
91
- LlmProxyTypeService: "https://sbqznqszdlqhjn4p4nfhtst6ra0wngjc.lambda-url.us-east-1.on.aws/"
87
+ CustomTypeService: "https://api.internal.prismic.io/custom-type/"
92
88
  };
93
89
  }
94
90
  }
@@ -1 +1 @@
1
- {"version":3,"file":"API_ENDPOINTS.cjs","sources":["../../../src/constants/API_ENDPOINTS.ts"],"sourcesContent":["import { addTrailingSlash, removeTrailingSlash } from \"../lib/trailingSlash\";\nimport { APPLICATION_MODE } from \"./APPLICATION_MODE\";\n\nexport type APIEndpoints = {\n\tPrismicWroom: string;\n\tPrismicAuthentication: string;\n\tPrismicModels: string;\n\tPrismicUser: string;\n\tAwsAclProvider: string;\n\tPrismicEmbed: string;\n\tPrismicUnsplash: string;\n\tSliceMachineV1: string;\n\tRepositoryService: string;\n\tLocaleService: string;\n\tCustomTypeService: string;\n\tLlmProxyTypeService: string;\n};\n\nexport const API_ENDPOINTS: APIEndpoints = (() => {\n\tswitch (process.env.SM_ENV) {\n\t\tcase APPLICATION_MODE.Development: {\n\t\t\tconst apiEndpoints = {\n\t\t\t\tPrismicWroom: addTrailingSlash(process.env.wroom_endpoint),\n\t\t\t\tPrismicAuthentication: addTrailingSlash(\n\t\t\t\t\tprocess.env.authentication_server_endpoint,\n\t\t\t\t),\n\t\t\t\tPrismicModels: addTrailingSlash(process.env.customtypesapi_endpoint),\n\t\t\t\tPrismicUser: addTrailingSlash(process.env.user_service_endpoint),\n\t\t\t\tAwsAclProvider: addTrailingSlash(process.env.acl_provider_endpoint),\n\t\t\t\tPrismicEmbed: removeTrailingSlash(\n\t\t\t\t\tprocess.env.oembed_endpoint ?? \"https://oembed.wroom.io\",\n\t\t\t\t),\n\t\t\t\tPrismicUnsplash: addTrailingSlash(\n\t\t\t\t\tprocess.env.unsplash_endpoint ?? \"https://unsplash.wroom.io/\",\n\t\t\t\t),\n\t\t\t\tSliceMachineV1: addTrailingSlash(\n\t\t\t\t\tprocess.env.slice_machine_v1_endpoint ??\n\t\t\t\t\t\t\"https://sm-api.wroom.io/v1/\",\n\t\t\t\t),\n\t\t\t\tRepositoryService: addTrailingSlash(\n\t\t\t\t\tprocess.env.repository_api ??\n\t\t\t\t\t\t\"https://api.internal.wroom.io/repository/\",\n\t\t\t\t),\n\t\t\t\tLocaleService: addTrailingSlash(\n\t\t\t\t\tprocess.env.locale_api ?? \"https://api.internal.wroom.io/locale/\",\n\t\t\t\t),\n\t\t\t\tCustomTypeService: addTrailingSlash(\n\t\t\t\t\tprocess.env.custom_type_api ??\n\t\t\t\t\t\t\"https://api.internal.wroom.io/custom-type/\",\n\t\t\t\t),\n\t\t\t\tLlmProxyTypeService: addTrailingSlash(\n\t\t\t\t\tprocess.env.llm_proxy_api ??\n\t\t\t\t\t\t\"https://sbqznqszdlqhjn4p4nfhtst6ra0wngjc.lambda-url.us-east-1.on.aws/\",\n\t\t\t\t),\n\t\t\t};\n\n\t\t\tconst missingAPIEndpoints = Object.keys(apiEndpoints).filter((key) => {\n\t\t\t\treturn !apiEndpoints[key as keyof typeof apiEndpoints];\n\t\t\t});\n\n\t\t\tif (missingAPIEndpoints.length > 0) {\n\t\t\t\tconsole.error(\n\t\t\t\t\t`You are running Slice Machine in development mode (SM_ENV=${\n\t\t\t\t\t\tAPPLICATION_MODE.Development\n\t\t\t\t\t}) where API endpoints are configured via environment variables.\n\nThe following endpoints were not configured: ${missingAPIEndpoints.join(\", \")}.\n\nConfigure them before continuing.`,\n\t\t\t\t);\n\n\t\t\t\tprocess.exit(1);\n\t\t\t}\n\n\t\t\tconsole.warn(`You are running Slice Machine in development mode (SM_ENV=${\n\t\t\t\tAPPLICATION_MODE.Development\n\t\t\t}).\n\nThe following API endpoints were configured via environment variables:\n${Object.entries(apiEndpoints)\n\t.map(([name, endpoint]) => ` - ${name}: ${endpoint}`)\n\t.join(\"\\n\")}\n\nThese endpoints are different than Slice Machine's normal endpoints and are not trusted.\n\nIf you didn't intend to run Slice Machine this way, stop it immediately and unset the SM_ENV environment variable.`);\n\n\t\t\treturn apiEndpoints as APIEndpoints;\n\t\t}\n\n\t\tcase APPLICATION_MODE.Staging: {\n\t\t\treturn {\n\t\t\t\tPrismicWroom: \"https://wroom.io/\",\n\t\t\t\tPrismicAuthentication: \"https://auth.wroom.io/\",\n\t\t\t\tPrismicModels: \"https://customtypes.wroom.io/\",\n\t\t\t\tPrismicUser: \"https://user-service.wroom.io/\",\n\t\t\t\tAwsAclProvider: \"https://acl-provider.wroom.io/\",\n\t\t\t\tPrismicEmbed: \"https://oembed.wroom.io\",\n\t\t\t\tPrismicUnsplash: \"https://unsplash.wroom.io/\",\n\t\t\t\tSliceMachineV1: \"https://sm-api.wroom.io/v1/\",\n\t\t\t\tRepositoryService: \"https://api.internal.wroom.io/repository/\",\n\t\t\t\tLocaleService: \"https://api.internal.wroom.io/locale/\",\n\t\t\t\tCustomTypeService: \"https://api.internal.wroom.io/custom-type/\",\n\t\t\t\tLlmProxyTypeService:\n\t\t\t\t\t\"https://sbqznqszdlqhjn4p4nfhtst6ra0wngjc.lambda-url.us-east-1.on.aws/\",\n\t\t\t};\n\t\t}\n\n\t\tcase APPLICATION_MODE.DevTools:\n\t\tcase APPLICATION_MODE.MarketingTools:\n\t\tcase APPLICATION_MODE.Platform: {\n\t\t\treturn {\n\t\t\t\tPrismicWroom: `https://${process.env.SM_ENV}-wroom.com/`,\n\t\t\t\tPrismicAuthentication: `https://auth.${process.env.SM_ENV}-wroom.com/`,\n\t\t\t\tPrismicModels: `https://customtypes.${process.env.SM_ENV}-wroom.com/`,\n\t\t\t\tPrismicUser: `https://user-service.${process.env.SM_ENV}-wroom.com/`,\n\t\t\t\tAwsAclProvider: `https://acl-provider.${process.env.SM_ENV}-wroom.com/`,\n\t\t\t\tPrismicEmbed: `https://oembed.${process.env.SM_ENV}-wroom.com`,\n\t\t\t\tPrismicUnsplash: `https://unsplash.${process.env.SM_ENV}-wroom.com/`,\n\t\t\t\tSliceMachineV1: `https://sm-api.${process.env.SM_ENV}-wroom.com/v1/`,\n\t\t\t\tRepositoryService: `https://api.internal.${process.env.SM_ENV}-wroom.com/repository/`,\n\t\t\t\tLocaleService: `https://api.internal.${process.env.SM_ENV}-wroom.com/locale/`,\n\t\t\t\tCustomTypeService: `https://api.internal.${process.env.SM_ENV}-wroom.com/custom-type/`,\n\t\t\t\tLlmProxyTypeService:\n\t\t\t\t\t\"https://sbqznqszdlqhjn4p4nfhtst6ra0wngjc.lambda-url.us-east-1.on.aws/\",\n\t\t\t};\n\t\t}\n\n\t\tcase APPLICATION_MODE.Production:\n\t\tdefault: {\n\t\t\treturn {\n\t\t\t\tPrismicWroom: \"https://prismic.io/\",\n\t\t\t\tPrismicAuthentication: \"https://auth.prismic.io/\",\n\t\t\t\tPrismicModels: \"https://customtypes.prismic.io/\",\n\t\t\t\tPrismicUser: \"https://user-service.prismic.io/\",\n\t\t\t\tAwsAclProvider: \"https://acl-provider.prismic.io/\",\n\t\t\t\tPrismicEmbed: \"https://oembed.prismic.io\",\n\t\t\t\tPrismicUnsplash: \"https://unsplash.prismic.io/\",\n\t\t\t\tSliceMachineV1: \"https://sm-api.prismic.io/v1/\",\n\t\t\t\tRepositoryService: \"https://api.internal.prismic.io/repository/\",\n\t\t\t\tLocaleService: \"https://api.internal.prismic.io/locale/\",\n\t\t\t\tCustomTypeService: \"https://api.internal.prismic.io/custom-type/\",\n\t\t\t\tLlmProxyTypeService:\n\t\t\t\t\t\"https://sbqznqszdlqhjn4p4nfhtst6ra0wngjc.lambda-url.us-east-1.on.aws/\",\n\t\t\t};\n\t\t}\n\t}\n})();\n"],"names":["APPLICATION_MODE","addTrailingSlash","removeTrailingSlash"],"mappings":";;;;AAkBO,MAAM,iBAA+B,MAAK;AAChD,UAAQ,QAAQ,IAAI,QAAA;AAAA,IACnB,KAAKA,iBAAAA,iBAAiB,aAAa;AAClC,YAAM,eAAe;AAAA,QACpB,cAAcC,cAAAA,iBAAiB,QAAQ,IAAI,cAAc;AAAA,QACzD,uBAAuBA,cAAAA,iBACtB,QAAQ,IAAI,8BAA8B;AAAA,QAE3C,eAAeA,cAAAA,iBAAiB,QAAQ,IAAI,uBAAuB;AAAA,QACnE,aAAaA,cAAAA,iBAAiB,QAAQ,IAAI,qBAAqB;AAAA,QAC/D,gBAAgBA,cAAAA,iBAAiB,QAAQ,IAAI,qBAAqB;AAAA,QAClE,cAAcC,cAAAA,oBACb,QAAQ,IAAI,mBAAmB,yBAAyB;AAAA,QAEzD,iBAAiBD,cAAAA,iBAChB,QAAQ,IAAI,qBAAqB,4BAA4B;AAAA,QAE9D,gBAAgBA,cAAAA,iBACf,QAAQ,IAAI,6BACX,6BAA6B;AAAA,QAE/B,mBAAmBA,cAAAA,iBAClB,QAA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Q,IAAI,MAAM;AAAA,QAC3C,uBAAuB,gBAAgB,QAAQ,IAAI,MAAM;AAAA,QACzD,eAAe,uBAAuB,QAAQ,IAAI,MAAM;AAAA,QACxD,aAAa,wBAAwB,QAAQ,IAAI,MAAM;AAAA,QACvD,gBAAgB,wBAAwB,QAAQ,IAAI,MAAM;AAAA,QAC1D,cAAc,kBAAkB,QAAQ,IAAI,MAAM;AAAA,QAClD,iBAAiB,oBAAoB,QAAQ,IAAI,MAAM;AAAA,QACvD,gBAAgB,kBAAkB,QAAQ,IAAI,MAAM;AAAA,QACpD,mBAAmB,wBAAwB,QAAQ,IAAI,MAAM;AAAA,QAC7D,eAAe,wBAAwB,QAAQ,IAAI,MAAM;AAAA,QACzD,mBAAmB,wBAAwB,QAAQ,IAAI,MAAM;AAAA,QAC7D,qBACC;AAAA,MAAA;AAAA,IAEH;AAAA,IAEA,KAAKA,iBAAAA,iBAAiB;AAAA,IACtB,SAAS;AACR,aAAO;AAAA,QACN,cAAc;AAAA,QACd,uBAAuB;AAAA,QACvB,eAAe;AAAA,QACf,aAAa;AAAA,QACb,gBAAgB;AAAA,QAChB,cAAc;AAAA,QACd,iBAAiB;AAAA,QACjB,gBAAgB;AAAA,QAChB,mBAAmB;AAAA,QACnB,eAAe;AAAA,QACf,mBAAmB;AAAA,QACnB,qBACC;AAAA,MAAA;AAAA,IAEH;AAAA,EAAA;AAEF,GAAA;;"}
1
+ {"version":3,"file":"API_ENDPOINTS.cjs","sources":["../../../src/constants/API_ENDPOINTS.ts"],"sourcesContent":["import { addTrailingSlash, removeTrailingSlash } from \"../lib/trailingSlash\";\nimport { APPLICATION_MODE } from \"./APPLICATION_MODE\";\n\nexport type APIEndpoints = {\n\tPrismicWroom: string;\n\tPrismicAuthentication: string;\n\tPrismicModels: string;\n\tPrismicUser: string;\n\tAwsAclProvider: string;\n\tPrismicEmbed: string;\n\tPrismicUnsplash: string;\n\tSliceMachineV1: string;\n\tRepositoryService: string;\n\tLocaleService: string;\n\tCustomTypeService: string;\n};\n\nexport const API_ENDPOINTS: APIEndpoints = (() => {\n\tswitch (process.env.SM_ENV) {\n\t\tcase APPLICATION_MODE.Development: {\n\t\t\tconst apiEndpoints = {\n\t\t\t\tPrismicWroom: addTrailingSlash(process.env.wroom_endpoint),\n\t\t\t\tPrismicAuthentication: addTrailingSlash(\n\t\t\t\t\tprocess.env.authentication_server_endpoint,\n\t\t\t\t),\n\t\t\t\tPrismicModels: addTrailingSlash(process.env.customtypesapi_endpoint),\n\t\t\t\tPrismicUser: addTrailingSlash(process.env.user_service_endpoint),\n\t\t\t\tAwsAclProvider: addTrailingSlash(process.env.acl_provider_endpoint),\n\t\t\t\tPrismicEmbed: removeTrailingSlash(\n\t\t\t\t\tprocess.env.oembed_endpoint ?? \"https://oembed.wroom.io\",\n\t\t\t\t),\n\t\t\t\tPrismicUnsplash: addTrailingSlash(\n\t\t\t\t\tprocess.env.unsplash_endpoint ?? \"https://unsplash.wroom.io/\",\n\t\t\t\t),\n\t\t\t\tSliceMachineV1: addTrailingSlash(\n\t\t\t\t\tprocess.env.slice_machine_v1_endpoint ??\n\t\t\t\t\t\t\"https://sm-api.wroom.io/v1/\",\n\t\t\t\t),\n\t\t\t\tRepositoryService: addTrailingSlash(\n\t\t\t\t\tprocess.env.repository_api ??\n\t\t\t\t\t\t\"https://api.internal.wroom.io/repository/\",\n\t\t\t\t),\n\t\t\t\tLocaleService: addTrailingSlash(\n\t\t\t\t\tprocess.env.locale_api ?? \"https://api.internal.wroom.io/locale/\",\n\t\t\t\t),\n\t\t\t\tCustomTypeService: addTrailingSlash(\n\t\t\t\t\tprocess.env.custom_type_api ??\n\t\t\t\t\t\t\"https://api.internal.wroom.io/custom-type/\",\n\t\t\t\t),\n\t\t\t};\n\n\t\t\tconst missingAPIEndpoints = Object.keys(apiEndpoints).filter((key) => {\n\t\t\t\treturn !apiEndpoints[key as keyof typeof apiEndpoints];\n\t\t\t});\n\n\t\t\tif (missingAPIEndpoints.length > 0) {\n\t\t\t\tconsole.error(\n\t\t\t\t\t`You are running Slice Machine in development mode (SM_ENV=${\n\t\t\t\t\t\tAPPLICATION_MODE.Development\n\t\t\t\t\t}) where API endpoints are configured via environment variables.\n\nThe following endpoints were not configured: ${missingAPIEndpoints.join(\", \")}.\n\nConfigure them before continuing.`,\n\t\t\t\t);\n\n\t\t\t\tprocess.exit(1);\n\t\t\t}\n\n\t\t\tconsole.warn(`You are running Slice Machine in development mode (SM_ENV=${\n\t\t\t\tAPPLICATION_MODE.Development\n\t\t\t}).\n\nThe following API endpoints were configured via environment variables:\n${Object.entries(apiEndpoints)\n\t.map(([name, endpoint]) => ` - ${name}: ${endpoint}`)\n\t.join(\"\\n\")}\n\nThese endpoints are different than Slice Machine's normal endpoints and are not trusted.\n\nIf you didn't intend to run Slice Machine this way, stop it immediately and unset the SM_ENV environment variable.`);\n\n\t\t\treturn apiEndpoints as APIEndpoints;\n\t\t}\n\n\t\tcase APPLICATION_MODE.Staging: {\n\t\t\treturn {\n\t\t\t\tPrismicWroom: \"https://wroom.io/\",\n\t\t\t\tPrismicAuthentication: \"https://auth.wroom.io/\",\n\t\t\t\tPrismicModels: \"https://customtypes.wroom.io/\",\n\t\t\t\tPrismicUser: \"https://user-service.wroom.io/\",\n\t\t\t\tAwsAclProvider: \"https://acl-provider.wroom.io/\",\n\t\t\t\tPrismicEmbed: \"https://oembed.wroom.io\",\n\t\t\t\tPrismicUnsplash: \"https://unsplash.wroom.io/\",\n\t\t\t\tSliceMachineV1: \"https://sm-api.wroom.io/v1/\",\n\t\t\t\tRepositoryService: \"https://api.internal.wroom.io/repository/\",\n\t\t\t\tLocaleService: \"https://api.internal.wroom.io/locale/\",\n\t\t\t\tCustomTypeService: \"https://api.internal.wroom.io/custom-type/\",\n\t\t\t};\n\t\t}\n\n\t\tcase APPLICATION_MODE.DevTools:\n\t\tcase APPLICATION_MODE.MarketingTools:\n\t\tcase APPLICATION_MODE.Platform: {\n\t\t\treturn {\n\t\t\t\tPrismicWroom: `https://${process.env.SM_ENV}-wroom.com/`,\n\t\t\t\tPrismicAuthentication: `https://auth.${process.env.SM_ENV}-wroom.com/`,\n\t\t\t\tPrismicModels: `https://customtypes.${process.env.SM_ENV}-wroom.com/`,\n\t\t\t\tPrismicUser: `https://user-service.${process.env.SM_ENV}-wroom.com/`,\n\t\t\t\tAwsAclProvider: `https://acl-provider.${process.env.SM_ENV}-wroom.com/`,\n\t\t\t\tPrismicEmbed: `https://oembed.${process.env.SM_ENV}-wroom.com`,\n\t\t\t\tPrismicUnsplash: `https://unsplash.${process.env.SM_ENV}-wroom.com/`,\n\t\t\t\tSliceMachineV1: `https://sm-api.${process.env.SM_ENV}-wroom.com/v1/`,\n\t\t\t\tRepositoryService: `https://api.internal.${process.env.SM_ENV}-wroom.com/repository/`,\n\t\t\t\tLocaleService: `https://api.internal.${process.env.SM_ENV}-wroom.com/locale/`,\n\t\t\t\tCustomTypeService: `https://api.internal.${process.env.SM_ENV}-wroom.com/custom-type/`,\n\t\t\t};\n\t\t}\n\n\t\tcase APPLICATION_MODE.Production:\n\t\tdefault: {\n\t\t\treturn {\n\t\t\t\tPrismicWroom: \"https://prismic.io/\",\n\t\t\t\tPrismicAuthentication: \"https://auth.prismic.io/\",\n\t\t\t\tPrismicModels: \"https://customtypes.prismic.io/\",\n\t\t\t\tPrismicUser: \"https://user-service.prismic.io/\",\n\t\t\t\tAwsAclProvider: \"https://acl-provider.prismic.io/\",\n\t\t\t\tPrismicEmbed: \"https://oembed.prismic.io\",\n\t\t\t\tPrismicUnsplash: \"https://unsplash.prismic.io/\",\n\t\t\t\tSliceMachineV1: \"https://sm-api.prismic.io/v1/\",\n\t\t\t\tRepositoryService: \"https://api.internal.prismic.io/repository/\",\n\t\t\t\tLocaleService: \"https://api.internal.prismic.io/locale/\",\n\t\t\t\tCustomTypeService: \"https://api.internal.prismic.io/custom-type/\",\n\t\t\t};\n\t\t}\n\t}\n})();\n"],"names":["APPLICATION_MODE","addTrailingSlash","removeTrailingSlash"],"mapp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AgB;AAAA,QAChB,cAAc;AAAA,QACd,iBAAiB;AAAA,QACjB,gBAAgB;AAAA,QAChB,mBAAmB;AAAA,QACnB,eAAe;AAAA,QACf,mBAAmB;AAAA,MAAA;AAAA,IAErB;AAAA,EAAA;AAEF,GAAA;;"}
@@ -10,6 +10,5 @@ export type APIEndpoints = {
10
10
  RepositoryService: string;
11
11
  LocaleService: string;
12
12
  CustomTypeService: string;
13
- LlmProxyTypeService: string;
14
13
  };
15
14
  export declare const API_ENDPOINTS: APIEndpoints;
@@ -14,8 +14,7 @@ const API_ENDPOINTS = (() => {
14
14
  SliceMachineV1: addTrailingSlash(process.env.slice_machine_v1_endpoint ?? "https://sm-api.wroom.io/v1/"),
15
15
  RepositoryService: addTrailingSlash(process.env.repository_api ?? "https://api.internal.wroom.io/repository/"),
16
16
  LocaleService: addTrailingSlash(process.env.locale_api ?? "https://api.internal.wroom.io/locale/"),
17
- CustomTypeService: addTrailingSlash(process.env.custom_type_api ?? "https://api.internal.wroom.io/custom-type/"),
18
- LlmProxyTypeService: addTrailingSlash(process.env.llm_proxy_api ?? "https://sbqznqszdlqhjn4p4nfhtst6ra0wngjc.lambda-url.us-east-1.on.aws/")
17
+ CustomTypeService: addTrailingSlash(process.env.custom_type_api ?? "https://api.internal.wroom.io/custom-type/")
19
18
  };
20
19
  const missingAPIEndpoints = Object.keys(apiEndpoints).filter((key) => {
21
20
  return !apiEndpoints[key];
@@ -50,8 +49,7 @@ If you didn't intend to run Slice Machine this way, stop it immediately and unse
50
49
  SliceMachineV1: "https://sm-api.wroom.io/v1/",
51
50
  RepositoryService: "https://api.internal.wroom.io/repository/",
52
51
  LocaleService: "https://api.internal.wroom.io/locale/",
53
- CustomTypeService: "https://api.internal.wroom.io/custom-type/",
54
- LlmProxyTypeService: "https://sbqznqszdlqhjn4p4nfhtst6ra0wngjc.lambda-url.us-east-1.on.aws/"
52
+ CustomTypeService: "https://api.internal.wroom.io/custom-type/"
55
53
  };
56
54
  }
57
55
  case APPLICATION_MODE.DevTools:
@@ -68,8 +66,7 @@ If you didn't intend to run Slice Machine this way, stop it immediately and unse
68
66
  SliceMachineV1: `https://sm-api.${process.env.SM_ENV}-wroom.com/v1/`,
69
67
  RepositoryService: `https://api.internal.${process.env.SM_ENV}-wroom.com/repository/`,
70
68
  LocaleService: `https://api.internal.${process.env.SM_ENV}-wroom.com/locale/`,
71
- CustomTypeService: `https://api.internal.${process.env.SM_ENV}-wroom.com/custom-type/`,
72
- LlmProxyTypeService: "https://sbqznqszdlqhjn4p4nfhtst6ra0wngjc.lambda-url.us-east-1.on.aws/"
69
+ CustomTypeService: `https://api.internal.${process.env.SM_ENV}-wroom.com/custom-type/`
73
70
  };
74
71
  }
75
72
  case APPLICATION_MODE.Production:
@@ -85,8 +82,7 @@ If you didn't intend to run Slice Machine this way, stop it immediately and unse
85
82
  SliceMachineV1: "https://sm-api.prismic.io/v1/",
86
83
  RepositoryService: "https://api.internal.prismic.io/repository/",
87
84
  LocaleService: "https://api.internal.prismic.io/locale/",
88
- CustomTypeService: "https://api.internal.prismic.io/custom-type/",
89
- LlmProxyTypeService: "https://sbqznqszdlqhjn4p4nfhtst6ra0wngjc.lambda-url.us-east-1.on.aws/"
85
+ CustomTypeService: "https://api.internal.prismic.io/custom-type/"
90
86
  };
91
87
  }
92
88
  }
@@ -1 +1 @@
1
- {"version":3,"file":"API_ENDPOINTS.js","sources":["../../../src/constants/API_ENDPOINTS.ts"],"sourcesContent":["import { addTrailingSlash, removeTrailingSlash } from \"../lib/trailingSlash\";\nimport { APPLICATION_MODE } from \"./APPLICATION_MODE\";\n\nexport type APIEndpoints = {\n\tPrismicWroom: string;\n\tPrismicAuthentication: string;\n\tPrismicModels: string;\n\tPrismicUser: string;\n\tAwsAclProvider: string;\n\tPrismicEmbed: string;\n\tPrismicUnsplash: string;\n\tSliceMachineV1: string;\n\tRepositoryService: string;\n\tLocaleService: string;\n\tCustomTypeService: string;\n\tLlmProxyTypeService: string;\n};\n\nexport const API_ENDPOINTS: APIEndpoints = (() => {\n\tswitch (process.env.SM_ENV) {\n\t\tcase APPLICATION_MODE.Development: {\n\t\t\tconst apiEndpoints = {\n\t\t\t\tPrismicWroom: addTrailingSlash(process.env.wroom_endpoint),\n\t\t\t\tPrismicAuthentication: addTrailingSlash(\n\t\t\t\t\tprocess.env.authentication_server_endpoint,\n\t\t\t\t),\n\t\t\t\tPrismicModels: addTrailingSlash(process.env.customtypesapi_endpoint),\n\t\t\t\tPrismicUser: addTrailingSlash(process.env.user_service_endpoint),\n\t\t\t\tAwsAclProvider: addTrailingSlash(process.env.acl_provider_endpoint),\n\t\t\t\tPrismicEmbed: removeTrailingSlash(\n\t\t\t\t\tprocess.env.oembed_endpoint ?? \"https://oembed.wroom.io\",\n\t\t\t\t),\n\t\t\t\tPrismicUnsplash: addTrailingSlash(\n\t\t\t\t\tprocess.env.unsplash_endpoint ?? \"https://unsplash.wroom.io/\",\n\t\t\t\t),\n\t\t\t\tSliceMachineV1: addTrailingSlash(\n\t\t\t\t\tprocess.env.slice_machine_v1_endpoint ??\n\t\t\t\t\t\t\"https://sm-api.wroom.io/v1/\",\n\t\t\t\t),\n\t\t\t\tRepositoryService: addTrailingSlash(\n\t\t\t\t\tprocess.env.repository_api ??\n\t\t\t\t\t\t\"https://api.internal.wroom.io/repository/\",\n\t\t\t\t),\n\t\t\t\tLocaleService: addTrailingSlash(\n\t\t\t\t\tprocess.env.locale_api ?? \"https://api.internal.wroom.io/locale/\",\n\t\t\t\t),\n\t\t\t\tCustomTypeService: addTrailingSlash(\n\t\t\t\t\tprocess.env.custom_type_api ??\n\t\t\t\t\t\t\"https://api.internal.wroom.io/custom-type/\",\n\t\t\t\t),\n\t\t\t\tLlmProxyTypeService: addTrailingSlash(\n\t\t\t\t\tprocess.env.llm_proxy_api ??\n\t\t\t\t\t\t\"https://sbqznqszdlqhjn4p4nfhtst6ra0wngjc.lambda-url.us-east-1.on.aws/\",\n\t\t\t\t),\n\t\t\t};\n\n\t\t\tconst missingAPIEndpoints = Object.keys(apiEndpoints).filter((key) => {\n\t\t\t\treturn !apiEndpoints[key as keyof typeof apiEndpoints];\n\t\t\t});\n\n\t\t\tif (missingAPIEndpoints.length > 0) {\n\t\t\t\tconsole.error(\n\t\t\t\t\t`You are running Slice Machine in development mode (SM_ENV=${\n\t\t\t\t\t\tAPPLICATION_MODE.Development\n\t\t\t\t\t}) where API endpoints are configured via environment variables.\n\nThe following endpoints were not configured: ${missingAPIEndpoints.join(\", \")}.\n\nConfigure them before continuing.`,\n\t\t\t\t);\n\n\t\t\t\tprocess.exit(1);\n\t\t\t}\n\n\t\t\tconsole.warn(`You are running Slice Machine in development mode (SM_ENV=${\n\t\t\t\tAPPLICATION_MODE.Development\n\t\t\t}).\n\nThe following API endpoints were configured via environment variables:\n${Object.entries(apiEndpoints)\n\t.map(([name, endpoint]) => ` - ${name}: ${endpoint}`)\n\t.join(\"\\n\")}\n\nThese endpoints are different than Slice Machine's normal endpoints and are not trusted.\n\nIf you didn't intend to run Slice Machine this way, stop it immediately and unset the SM_ENV environment variable.`);\n\n\t\t\treturn apiEndpoints as APIEndpoints;\n\t\t}\n\n\t\tcase APPLICATION_MODE.Staging: {\n\t\t\treturn {\n\t\t\t\tPrismicWroom: \"https://wroom.io/\",\n\t\t\t\tPrismicAuthentication: \"https://auth.wroom.io/\",\n\t\t\t\tPrismicModels: \"https://customtypes.wroom.io/\",\n\t\t\t\tPrismicUser: \"https://user-service.wroom.io/\",\n\t\t\t\tAwsAclProvider: \"https://acl-provider.wroom.io/\",\n\t\t\t\tPrismicEmbed: \"https://oembed.wroom.io\",\n\t\t\t\tPrismicUnsplash: \"https://unsplash.wroom.io/\",\n\t\t\t\tSliceMachineV1: \"https://sm-api.wroom.io/v1/\",\n\t\t\t\tRepositoryService: \"https://api.internal.wroom.io/repository/\",\n\t\t\t\tLocaleService: \"https://api.internal.wroom.io/locale/\",\n\t\t\t\tCustomTypeService: \"https://api.internal.wroom.io/custom-type/\",\n\t\t\t\tLlmProxyTypeService:\n\t\t\t\t\t\"https://sbqznqszdlqhjn4p4nfhtst6ra0wngjc.lambda-url.us-east-1.on.aws/\",\n\t\t\t};\n\t\t}\n\n\t\tcase APPLICATION_MODE.DevTools:\n\t\tcase APPLICATION_MODE.MarketingTools:\n\t\tcase APPLICATION_MODE.Platform: {\n\t\t\treturn {\n\t\t\t\tPrismicWroom: `https://${process.env.SM_ENV}-wroom.com/`,\n\t\t\t\tPrismicAuthentication: `https://auth.${process.env.SM_ENV}-wroom.com/`,\n\t\t\t\tPrismicModels: `https://customtypes.${process.env.SM_ENV}-wroom.com/`,\n\t\t\t\tPrismicUser: `https://user-service.${process.env.SM_ENV}-wroom.com/`,\n\t\t\t\tAwsAclProvider: `https://acl-provider.${process.env.SM_ENV}-wroom.com/`,\n\t\t\t\tPrismicEmbed: `https://oembed.${process.env.SM_ENV}-wroom.com`,\n\t\t\t\tPrismicUnsplash: `https://unsplash.${process.env.SM_ENV}-wroom.com/`,\n\t\t\t\tSliceMachineV1: `https://sm-api.${process.env.SM_ENV}-wroom.com/v1/`,\n\t\t\t\tRepositoryService: `https://api.internal.${process.env.SM_ENV}-wroom.com/repository/`,\n\t\t\t\tLocaleService: `https://api.internal.${process.env.SM_ENV}-wroom.com/locale/`,\n\t\t\t\tCustomTypeService: `https://api.internal.${process.env.SM_ENV}-wroom.com/custom-type/`,\n\t\t\t\tLlmProxyTypeService:\n\t\t\t\t\t\"https://sbqznqszdlqhjn4p4nfhtst6ra0wngjc.lambda-url.us-east-1.on.aws/\",\n\t\t\t};\n\t\t}\n\n\t\tcase APPLICATION_MODE.Production:\n\t\tdefault: {\n\t\t\treturn {\n\t\t\t\tPrismicWroom: \"https://prismic.io/\",\n\t\t\t\tPrismicAuthentication: \"https://auth.prismic.io/\",\n\t\t\t\tPrismicModels: \"https://customtypes.prismic.io/\",\n\t\t\t\tPrismicUser: \"https://user-service.prismic.io/\",\n\t\t\t\tAwsAclProvider: \"https://acl-provider.prismic.io/\",\n\t\t\t\tPrismicEmbed: \"https://oembed.prismic.io\",\n\t\t\t\tPrismicUnsplash: \"https://unsplash.prismic.io/\",\n\t\t\t\tSliceMachineV1: \"https://sm-api.prismic.io/v1/\",\n\t\t\t\tRepositoryService: \"https://api.internal.prismic.io/repository/\",\n\t\t\t\tLocaleService: \"https://api.internal.prismic.io/locale/\",\n\t\t\t\tCustomTypeService: \"https://api.internal.prismic.io/custom-type/\",\n\t\t\t\tLlmProxyTypeService:\n\t\t\t\t\t\"https://sbqznqszdlqhjn4p4nfhtst6ra0wngjc.lambda-url.us-east-1.on.aws/\",\n\t\t\t};\n\t\t}\n\t}\n})();\n"],"names":[],"mappings":";;AAkBO,MAAM,iBAA+B,MAAK;AAChD,UAAQ,QAAQ,IAAI,QAAA;AAAA,IACnB,KAAK,iBAAiB,aAAa;AAClC,YAAM,eAAe;AAAA,QACpB,cAAc,iBAAiB,QAAQ,IAAI,cAAc;AAAA,QACzD,uBAAuB,iBACtB,QAAQ,IAAI,8BAA8B;AAAA,QAE3C,eAAe,iBAAiB,QAAQ,IAAI,uBAAuB;AAAA,QACnE,aAAa,iBAAiB,QAAQ,IAAI,qBAAqB;AAAA,QAC/D,gBAAgB,iBAAiB,QAAQ,IAAI,qBAAqB;AAAA,QAClE,cAAc,oBACb,QAAQ,IAAI,mBAAmB,yBAAyB;AAAA,QAEzD,iBAAiB,iBAChB,QAAQ,IAAI,qBAAqB,4BAA4B;AAAA,QAE9D,gBAAgB,iBACf,QAAQ,IAAI,6BACX,6BAA6B;AAAA,QAE/B,mBAAmB,iBAClB,QAAQ,IAAI,kBACX,2CAA2C;AAAA,QAE7C,eAAe,iBACd,QAAQ,IAAI,cAAc,uCAAuC;AAAA,QAElE,mBAAmB,iBAClB,QAAQ,IAAI,mBACX,4CAA4C;AAAA,QAE9C,qBAAqB,iBACpB,QAAQ,IAAI,iBACX,uEAAuE;AAAA,MAAA;AAI1E,YAAM,sBAAsB,OAAO,KAAK,YAAY,EAAE,OAAO,CAAC,QAAO;AACpE,e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QACpD,mBAAmB,wBAAwB,QAAQ,IAAI,MAAM;AAAA,QAC7D,eAAe,wBAAwB,QAAQ,IAAI,MAAM;AAAA,QACzD,mBAAmB,wBAAwB,QAAQ,IAAI,MAAM;AAAA,QAC7D,qBACC;AAAA,MAAA;AAAA,IAEH;AAAA,IAEA,KAAK,iBAAiB;AAAA,IACtB,SAAS;AACR,aAAO;AAAA,QACN,cAAc;AAAA,QACd,uBAAuB;AAAA,QACvB,eAAe;AAAA,QACf,aAAa;AAAA,QACb,gBAAgB;AAAA,QAChB,cAAc;AAAA,QACd,iBAAiB;AAAA,QACjB,gBAAgB;AAAA,QAChB,mBAAmB;AAAA,QACnB,eAAe;AAAA,QACf,mBAAmB;AAAA,QACnB,qBACC;AAAA,MAAA;AAAA,IAEH;AAAA,EAAA;AAEF,GAAA;"}
1
+ {"version":3,"file":"API_ENDPOINTS.js","sources":["../../../src/constants/API_ENDPOINTS.ts"],"sourcesContent":["import { addTrailingSlash, removeTrailingSlash } from \"../lib/trailingSlash\";\nimport { APPLICATION_MODE } from \"./APPLICATION_MODE\";\n\nexport type APIEndpoints = {\n\tPrismicWroom: string;\n\tPrismicAuthentication: string;\n\tPrismicModels: string;\n\tPrismicUser: string;\n\tAwsAclProvider: string;\n\tPrismicEmbed: string;\n\tPrismicUnsplash: string;\n\tSliceMachineV1: string;\n\tRepositoryService: string;\n\tLocaleService: string;\n\tCustomTypeService: string;\n};\n\nexport const API_ENDPOINTS: APIEndpoints = (() => {\n\tswitch (process.env.SM_ENV) {\n\t\tcase APPLICATION_MODE.Development: {\n\t\t\tconst apiEndpoints = {\n\t\t\t\tPrismicWroom: addTrailingSlash(process.env.wroom_endpoint),\n\t\t\t\tPrismicAuthentication: addTrailingSlash(\n\t\t\t\t\tprocess.env.authentication_server_endpoint,\n\t\t\t\t),\n\t\t\t\tPrismicModels: addTrailingSlash(process.env.customtypesapi_endpoint),\n\t\t\t\tPrismicUser: addTrailingSlash(process.env.user_service_endpoint),\n\t\t\t\tAwsAclProvider: addTrailingSlash(process.env.acl_provider_endpoint),\n\t\t\t\tPrismicEmbed: removeTrailingSlash(\n\t\t\t\t\tprocess.env.oembed_endpoint ?? \"https://oembed.wroom.io\",\n\t\t\t\t),\n\t\t\t\tPrismicUnsplash: addTrailingSlash(\n\t\t\t\t\tprocess.env.unsplash_endpoint ?? \"https://unsplash.wroom.io/\",\n\t\t\t\t),\n\t\t\t\tSliceMachineV1: addTrailingSlash(\n\t\t\t\t\tprocess.env.slice_machine_v1_endpoint ??\n\t\t\t\t\t\t\"https://sm-api.wroom.io/v1/\",\n\t\t\t\t),\n\t\t\t\tRepositoryService: addTrailingSlash(\n\t\t\t\t\tprocess.env.repository_api ??\n\t\t\t\t\t\t\"https://api.internal.wroom.io/repository/\",\n\t\t\t\t),\n\t\t\t\tLocaleService: addTrailingSlash(\n\t\t\t\t\tprocess.env.locale_api ?? \"https://api.internal.wroom.io/locale/\",\n\t\t\t\t),\n\t\t\t\tCustomTypeService: addTrailingSlash(\n\t\t\t\t\tprocess.env.custom_type_api ??\n\t\t\t\t\t\t\"https://api.internal.wroom.io/custom-type/\",\n\t\t\t\t),\n\t\t\t};\n\n\t\t\tconst missingAPIEndpoints = Object.keys(apiEndpoints).filter((key) => {\n\t\t\t\treturn !apiEndpoints[key as keyof typeof apiEndpoints];\n\t\t\t});\n\n\t\t\tif (missingAPIEndpoints.length > 0) {\n\t\t\t\tconsole.error(\n\t\t\t\t\t`You are running Slice Machine in development mode (SM_ENV=${\n\t\t\t\t\t\tAPPLICATION_MODE.Development\n\t\t\t\t\t}) where API endpoints are configured via environment variables.\n\nThe following endpoints were not configured: ${missingAPIEndpoints.join(\", \")}.\n\nConfigure them before continuing.`,\n\t\t\t\t);\n\n\t\t\t\tprocess.exit(1);\n\t\t\t}\n\n\t\t\tconsole.warn(`You are running Slice Machine in development mode (SM_ENV=${\n\t\t\t\tAPPLICATION_MODE.Development\n\t\t\t}).\n\nThe following API endpoints were configured via environment variables:\n${Object.entries(apiEndpoints)\n\t.map(([name, endpoint]) => ` - ${name}: ${endpoint}`)\n\t.join(\"\\n\")}\n\nThese endpoints are different than Slice Machine's normal endpoints and are not trusted.\n\nIf you didn't intend to run Slice Machine this way, stop it immediately and unset the SM_ENV environment variable.`);\n\n\t\t\treturn apiEndpoints as APIEndpoints;\n\t\t}\n\n\t\tcase APPLICATION_MODE.Staging: {\n\t\t\treturn {\n\t\t\t\tPrismicWroom: \"https://wroom.io/\",\n\t\t\t\tPrismicAuthentication: \"https://auth.wroom.io/\",\n\t\t\t\tPrismicModels: \"https://customtypes.wroom.io/\",\n\t\t\t\tPrismicUser: \"https://user-service.wroom.io/\",\n\t\t\t\tAwsAclProvider: \"https://acl-provider.wroom.io/\",\n\t\t\t\tPrismicEmbed: \"https://oembed.wroom.io\",\n\t\t\t\tPrismicUnsplash: \"https://unsplash.wroom.io/\",\n\t\t\t\tSliceMachineV1: \"https://sm-api.wroom.io/v1/\",\n\t\t\t\tRepositoryService: \"https://api.internal.wroom.io/repository/\",\n\t\t\t\tLocaleService: \"https://api.internal.wroom.io/locale/\",\n\t\t\t\tCustomTypeService: \"https://api.internal.wroom.io/custom-type/\",\n\t\t\t};\n\t\t}\n\n\t\tcase APPLICATION_MODE.DevTools:\n\t\tcase APPLICATION_MODE.MarketingTools:\n\t\tcase APPLICATION_MODE.Platform: {\n\t\t\treturn {\n\t\t\t\tPrismicWroom: `https://${process.env.SM_ENV}-wroom.com/`,\n\t\t\t\tPrismicAuthentication: `https://auth.${process.env.SM_ENV}-wroom.com/`,\n\t\t\t\tPrismicModels: `https://customtypes.${process.env.SM_ENV}-wroom.com/`,\n\t\t\t\tPrismicUser: `https://user-service.${process.env.SM_ENV}-wroom.com/`,\n\t\t\t\tAwsAclProvider: `https://acl-provider.${process.env.SM_ENV}-wroom.com/`,\n\t\t\t\tPrismicEmbed: `https://oembed.${process.env.SM_ENV}-wroom.com`,\n\t\t\t\tPrismicUnsplash: `https://unsplash.${process.env.SM_ENV}-wroom.com/`,\n\t\t\t\tSliceMachineV1: `https://sm-api.${process.env.SM_ENV}-wroom.com/v1/`,\n\t\t\t\tRepositoryService: `https://api.internal.${process.env.SM_ENV}-wroom.com/repository/`,\n\t\t\t\tLocaleService: `https://api.internal.${process.env.SM_ENV}-wroom.com/locale/`,\n\t\t\t\tCustomTypeService: `https://api.internal.${process.env.SM_ENV}-wroom.com/custom-type/`,\n\t\t\t};\n\t\t}\n\n\t\tcase APPLICATION_MODE.Production:\n\t\tdefault: {\n\t\t\treturn {\n\t\t\t\tPrismicWroom: \"https://prismic.io/\",\n\t\t\t\tPrismicAuthentication: \"https://auth.prismic.io/\",\n\t\t\t\tPrismicModels: \"https://customtypes.prismic.io/\",\n\t\t\t\tPrismicUser: \"https://user-service.prismic.io/\",\n\t\t\t\tAwsAclProvider: \"https://acl-provider.prismic.io/\",\n\t\t\t\tPrismicEmbed: \"https://oembed.prismic.io\",\n\t\t\t\tPrismicUnsplash: \"https://unsplash.prismic.io/\",\n\t\t\t\tSliceMachineV1: \"https://sm-api.prismic.io/v1/\",\n\t\t\t\tRepositoryService: \"https://api.internal.prismic.io/repository/\",\n\t\t\t\tLocaleService: \"https://api.internal.prismic.io/locale/\",\n\t\t\t\tCustomTypeService: \"https://api.internal.prismic.io/custom-type/\",\n\t\t\t};\n\t\t}\n\t}\n})();\n"],"names":[],"mappings":";;AAiBO,MAAM,iBAA+B,MAAK;AAChD,UAAQ,QAAQ,IAAI,QAAA;AAAA,IACnB,KAAK,iBAAiB,aAAa;AAClC,YAAM,eAAe;AAAA,QACpB,cAAc,iBAAiB,QAAQ,IAAI,cAAc;AAAA,QACzD,uBAAuB,iBACtB,QAAQ,IAAI,8BAA8B;AAAA,QAE3C,eAAe,iBAAiB,QAAQ,IAAI,uBAAuB;AAAA,QACnE,aAAa,iBAAiB,QAAQ,IAAI,qBAAqB;AAAA,QAC/D,gBAAgB,iBAAiB,QAAQ,IAAI,qBAAqB;AAAA,QAClE,cAAc,oBACb,QAAQ,IAAI,mBAAm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AQ,IAAI,MAAM;AAAA,QAC3C,uBAAuB,gBAAgB,QAAQ,IAAI,MAAM;AAAA,QACzD,eAAe,uBAAuB,QAAQ,IAAI,MAAM;AAAA,QACxD,aAAa,wBAAwB,QAAQ,IAAI,MAAM;AAAA,QACvD,gBAAgB,wBAAwB,QAAQ,IAAI,MAAM;AAAA,QAC1D,cAAc,kBAAkB,QAAQ,IAAI,MAAM;AAAA,QAClD,iBAAiB,oBAAoB,QAAQ,IAAI,MAAM;AAAA,QACvD,gBAAgB,kBAAkB,QAAQ,IAAI,MAAM;AAAA,QACpD,mBAAmB,wBAAwB,QAAQ,IAAI,MAAM;AAAA,QAC7D,eAAe,wBAAwB,QAAQ,IAAI,MAAM;AAAA,QACzD,mBAAmB,wBAAwB,QAAQ,IAAI,MAAM;AAAA,MAAA;AAAA,IAE/D;AAAA,IAEA,KAAK,iBAAiB;AAAA,IACtB,SAAS;AACR,aAAO;AAAA,QACN,cAAc;AAAA,QACd,uBAAuB;AAAA,QACvB,eAAe;AAAA,QACf,aAAa;AAAA,QACb,gBAAgB;AAAA,QAChB,cAAc;AAAA,QACd,iBAAiB;AAAA,QACjB,gBAAgB;AAAA,QAChB,mBAAmB;AAAA,QACnB,eAAe;AAAA,QACf,mBAAmB;AAAA,MAAA;AAAA,IAErB;AAAA,EAAA;AAEF,GAAA;"}
@@ -300,6 +300,11 @@ class CustomTypesManager extends BaseManager.BaseManager {
300
300
  async inferSlice(args) {
301
301
  var _a;
302
302
  const { source, imageUrl } = args;
303
+ const exp = await this.telemetry.getExperimentVariant("llm-proxy-access");
304
+ if ((exp == null ? void 0 : exp.value) !== "on") {
305
+ throw new Error("LLM proxy access is not enabled.");
306
+ }
307
+ const { llmProxyUrl } = index.default.object({ llmProxyUrl: index.default.string() }).parse(exp.payload);
303
308
  const authToken = await this.user.getAuthenticationToken();
304
309
  const repository = await this.project.getResolvedRepositoryName();
305
310
  if (source === "figma") {
@@ -502,7 +507,7 @@ FINAL REMINDERS:
502
507
  ],
503
508
  env: {
504
509
  ...process.env,
505
- ANTHROPIC_BASE_URL: API_ENDPOINTS.API_ENDPOINTS.LlmProxyTypeService,
510
+ ANTHROPIC_BASE_URL: llmProxyUrl,
506
511
  ANTHROPIC_CUSTOM_HEADERS: `x-prismic-token: ${authToken}
507
512
  x-prismic-repository: ${repository}
508
513
  `
@@ -1 +1 @@
1
- {"version":3,"file":"CustomTypesManager.cjs","sources":["../../../../src/managers/customTypes/CustomTypesManager.ts"],"sourcesContent":["import * as t from \"io-ts\";\nimport * as prismicCustomTypesClient from \"@prismicio/custom-types-client\";\nimport {\n\tCustomType,\n\tGroup,\n\tLinkConfig,\n\tNestableWidget,\n\tNestedGroup,\n\tSharedSlice,\n\tUID,\n\ttraverseCustomType,\n\ttraverseSharedSlice,\n} from \"@prismicio/types-internal/lib/customtypes\";\nimport {\n\tCallHookReturnType,\n\tCustomTypeCreateHook,\n\tCustomTypeCreateHookData,\n\tCustomTypeReadHookData,\n\tCustomTypeRenameHook,\n\tCustomTypeRenameHookData,\n\tCustomTypeUpdateHook,\n\tCustomTypeUpdateHookData,\n\tHookError,\n} from \"@slicemachine/plugin-kit\";\nimport { z } from \"zod\";\nimport { query as queryClaude } from \"@anthropic-ai/claude-agent-sdk\";\n\nimport { DecodeError } from \"../../lib/DecodeError\";\nimport { assertPluginsInitialized } from \"../../lib/assertPluginsInitialized\";\nimport { decodeHookResult } from \"../../lib/decodeHookResult\";\nimport fetch from \"../../lib/fetch\";\n\nimport { OnlyHookErrors } from \"../../types\";\nimport { API_ENDPOINTS } from \"../../constants/API_ENDPOINTS\";\nimport { SLICE_MACHINE_USER_AGENT } from \"../../constants/SLICE_MACHINE_USER_AGENT\";\nimport { UnauthorizedError } from \"../../errors\";\nimport { mkdtemp, readFile, rename, rm, writeFile } from \"fs/promises\";\nimport { tmpdir } from \"os\";\nimport path from \"path\";\nimport { randomUUID } from \"crypto\";\nimport { existsSync } from \"fs\";\n\nimport { BaseManager } from \"../BaseManager\";\nimport { CustomTypeFormat } from \"./types\";\n\ntype SliceMachineManagerReadCustomTypeLibraryReturnType = {\n\tids: string[];\n\terrors: (DecodeError | HookError)[];\n};\n\ntype CustomTypesManagerReadAllCustomTypesArgs = {\n\tformat: CustomTypeFormat;\n};\n\ntype SliceMachineManagerReadAllCustomTypeReturnType = {\n\tmodels: { model: CustomType }[];\n\terrors: (DecodeError | HookError)[];\n};\n\ntype SliceMachineManagerReadCustomTypeReturnType = {\n\tmodel: CustomType | undefined;\n\terrors: (DecodeError | HookError)[];\n};\n\ntype SliceMachineManagerPushCustomTypeArgs = {\n\tid: string;\n\tuserAgent?: string;\n};\n\ntype SliceMachineManagerReadCustomTypeMocksConfigArgs = {\n\tcustomTypeID: string;\n};\n\ntype SliceMachineManagerReadCustomTypeMocksConfigArgsReturnType = {\n\t// TODO\n\tmocksConfig?: Record<string, unknown>;\n\terrors: HookError[];\n};\n\ntype SliceMachineManagerUpdateCustomTypeMocksConfigArgs = {\n\tcustomTypeID: string;\n\t// TODO\n\tmocksConfig: Record<string, unknown>;\n};\n\n/** `[field]` or `[group, field]` – path **inside** the Custom Type */\ntype PathWithoutCustomType = [string] | [string, string];\n\ntype SliceMachineManagerUpdateCustomTypeFieldIdChanged = {\n\t/**\n\t * Previous path of the changed field, excluding the custom type id. Can be\n\t * used to identify the field that had an API ID rename (e.g. [\"fieldA\"] or\n\t * [\"groupA\", \"fieldA\"])\n\t */\n\tpreviousPath: PathWithoutCustomType;\n\t/**\n\t * New path of the changed field, excluding the custom type id. Can be used to\n\t * identify the field that had an API ID rename (e.g. [\"fieldB\"] or [\"groupA\",\n\t * \"fieldB\"])\n\t */\n\tnewPath: PathWithoutCustomType;\n};\n\ntype SliceMachineManagerUpdateCustomTypeArgs = CustomTypeUpdateHookData & {\n\tupdateMeta?: {\n\t\tfieldIdChanged?: SliceMachineManagerUpdateCustomTypeFieldIdChanged;\n\t};\n};\n\ntype SliceMachineManagerUpdateCustomTypeMocksConfigArgsReturnType = {\n\terrors: HookError[];\n};\n\ntype CustomTypesMachineManagerDeleteCustomTypeArgs = {\n\tid: string;\n};\n\ntype CustomTypesMachineManagerDeleteCustomTypeReturnType = {\n\terrors: (DecodeError | HookError)[];\n};\n\ntype CustomTypesMachineManagerUpdateCustomTypeReturnType = {\n\terrors: (DecodeError | HookError)[];\n};\n\n/** `[ct, field]` or `[ct, group, field]` – path **with** Custom Type ID */\ntype PathWithCustomType = [string, string] | [string, string, string];\n\ntype CustomTypeFieldIdChangedMeta = {\n\tpreviousPath: PathWithCustomType;\n\tnewPath: PathWithCustomType;\n};\n\ntype LinkCustomType = NonNullable<LinkConfig[\"customtypes\"]>[number];\n\nexport class CustomTypesManager extends BaseManager {\n\tasync readCustomTypeLibrary(): Promise<SliceMachineManagerReadCustomTypeLibraryReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type-library:read\",\n\t\t\tundefined,\n\t\t);\n\t\tconst { data, errors } = decodeHookResult(\n\t\t\tt.type({\n\t\t\t\tids: t.array(t.string),\n\t\t\t}),\n\t\t\thookResult,\n\t\t);\n\n\t\treturn {\n\t\t\tids: data[0]?.ids || [],\n\t\t\terrors,\n\t\t};\n\t}\n\n\tasync readAllCustomTypes(\n\t\targs?: CustomTypesManagerReadAllCustomTypesArgs,\n\t): Promise<SliceMachineManagerReadAllCustomTypeReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst res: SliceMachineManagerReadAllCustomTypeReturnType = {\n\t\t\tmodels: [],\n\t\t\terrors: [],\n\t\t};\n\n\t\tconst { ids, errors } = await this.readCustomTypeLibrary();\n\t\tres.errors = [...res.errors, ...errors];\n\n\t\tif (ids) {\n\t\t\tfor (const id of ids) {\n\t\t\t\tconst { model, errors } = await this.readCustomType({ id });\n\t\t\t\tres.errors = [...res.errors, ...errors];\n\n\t\t\t\tif (model && (!args || args.format === model.format)) {\n\t\t\t\t\tres.models.push({ model });\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn res;\n\t}\n\n\tasync createCustomType(\n\t\targs: CustomTypeCreateHookData,\n\t): Promise<OnlyHookErrors<CallHookReturnType<CustomTypeCreateHook>>> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:create\",\n\t\t\targs,\n\t\t);\n\n\t\treturn {\n\t\t\terrors: hookResult.errors,\n\t\t};\n\t}\n\n\tasync readCustomType(\n\t\targs: CustomTypeReadHookData,\n\t): Promise<SliceMachineManagerReadCustomTypeReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:read\",\n\t\t\targs,\n\t\t);\n\t\tconst { data, errors } = decodeHookResult(\n\t\t\tt.type({\n\t\t\t\tmodel: CustomType,\n\t\t\t}),\n\t\t\thookResult,\n\t\t);\n\n\t\treturn {\n\t\t\tmodel: data[0]?.model,\n\t\t\terrors,\n\t\t};\n\t}\n\n\t/**\n\t * Update the Content Relationship API IDs for all existing custom types and\n\t * slices. The change is determined by properties inside the `updateMeta`\n\t * property.\n\t */\n\tprivate async updateContentRelationships(\n\t\targs: {\n\t\t\tmodel: CustomType;\n\t\t} & SliceMachineManagerUpdateCustomTypeFieldIdChanged,\n\t): Promise<\n\t\tOnlyHookErrors<CallHookReturnType<CustomTypeUpdateHook>> & {\n\t\t\trollback?: () => Promise<void>;\n\t\t}\n\t> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst {\n\t\t\tmodel,\n\t\t\tpreviousPath: previousFieldPath,\n\t\t\tnewPath: newFieldPath,\n\t\t} = args;\n\n\t\tif (previousFieldPath.join(\".\") !== newFieldPath.join(\".\")) {\n\t\t\tconst { id: ctId } = model;\n\t\t\tconst previousPath: PathWithCustomType = [ctId, ...previousFieldPath];\n\t\t\tconst newPath: PathWithCustomType = [ctId, ...newFieldPath];\n\n\t\t\tconst crUpdates: {\n\t\t\t\tupdatePromise: Promise<{ errors: HookError[] }>;\n\t\t\t\trollback: () => void;\n\t\t\t}[] = [];\n\n\t\t\t// Find existing content relationships that link to the renamed field id in\n\t\t\t// any custom type and update them to use the new one.\n\t\t\tconst customTypes = await this.readAllCustomTypes();\n\n\t\t\tupdateCustomTypeContentRelationships({\n\t\t\t\tmodels: customTypes.models,\n\t\t\t\tonUpdate: ({ previousModel, model: updatedModel }) => {\n\t\t\t\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\t\t\t\tcrUpdates.push({\n\t\t\t\t\t\tupdatePromise: this.sliceMachinePluginRunner?.callHook(\n\t\t\t\t\t\t\t\"custom-type:update\",\n\t\t\t\t\t\t\t{ model: updatedModel },\n\t\t\t\t\t\t),\n\t\t\t\t\t\trollback: () => {\n\t\t\t\t\t\t\tthis.sliceMachinePluginRunner?.callHook(\"custom-type:update\", {\n\t\t\t\t\t\t\t\tmodel: previousModel,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t},\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\tpreviousPath,\n\t\t\t\tnewPath,\n\t\t\t});\n\n\t\t\t// Find existing slice with content relationships that link to the renamed\n\t\t\t// field id in all libraries and update them to use the new one.\n\t\t\tconst { libraries } = await this.slices.readAllSliceLibraries();\n\n\t\t\tfor (const library of libraries) {\n\t\t\t\tconst slices = await this.slices.readAllSlicesForLibrary({\n\t\t\t\t\tlibraryID: library.libraryID,\n\t\t\t\t});\n\n\t\t\t\tupdateSharedSliceContentRelationships({\n\t\t\t\t\tmodels: slices.models,\n\t\t\t\t\tonUpdate: ({ previousModel, model: updatedModel }) => {\n\t\t\t\t\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\t\t\t\t\tcrUpdates.push({\n\t\t\t\t\t\t\tupdatePromise: this.sliceMachinePluginRunner?.callHook(\n\t\t\t\t\t\t\t\t\"slice:update\",\n\t\t\t\t\t\t\t\t{ libraryID: library.libraryID, model: updatedModel },\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\trollback: () => {\n\t\t\t\t\t\t\t\tthis.sliceMachinePluginRunner?.callHook(\"slice:update\", {\n\t\t\t\t\t\t\t\t\tlibraryID: library.libraryID,\n\t\t\t\t\t\t\t\t\tmodel: previousModel,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t});\n\t\t\t\t\t},\n\t\t\t\t\tpreviousPath,\n\t\t\t\t\tnewPath,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// Process all the Content Relationship updates at once.\n\t\t\tconst crUpdatesResult = await Promise.all(\n\t\t\t\tcrUpdates.map((update) => update.updatePromise),\n\t\t\t);\n\n\t\t\tif (crUpdatesResult.some((result) => result.errors.length > 0)) {\n\t\t\t\treturn {\n\t\t\t\t\terrors: crUpdatesResult.flatMap((result) => result.errors),\n\t\t\t\t\trollback: async () => {\n\t\t\t\t\t\tawait Promise.all(crUpdates.map((update) => update.rollback()));\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\treturn { errors: [] };\n\t}\n\n\tasync updateCustomType(\n\t\targs: SliceMachineManagerUpdateCustomTypeArgs,\n\t): Promise<CustomTypesMachineManagerUpdateCustomTypeReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\t\tconst { model } = args;\n\t\tconst { fieldIdChanged } = args.updateMeta ?? {};\n\n\t\tlet previousCustomType: CustomType | undefined;\n\n\t\tif (fieldIdChanged) {\n\t\t\tconst customTypeRead = await this.readCustomType({ id: model.id });\n\n\t\t\tif (customTypeRead.errors.length > 0) {\n\t\t\t\treturn { errors: customTypeRead.errors };\n\t\t\t}\n\t\t\tif (!customTypeRead.model) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`readCustomType succeeded reading custom type ${model.id} but model is undefined.`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tpreviousCustomType = customTypeRead.model;\n\t\t}\n\n\t\tconst customTypeUpdateResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:update\",\n\t\t\t{ model },\n\t\t);\n\n\t\tif (customTypeUpdateResult.errors.length > 0) {\n\t\t\treturn { errors: customTypeUpdateResult.errors };\n\t\t}\n\n\t\tif (previousCustomType && fieldIdChanged) {\n\t\t\tconst crUpdateResult = await this.updateContentRelationships({\n\t\t\t\t...fieldIdChanged,\n\t\t\t\tmodel: previousCustomType,\n\t\t\t});\n\n\t\t\tif (crUpdateResult.errors.length > 0) {\n\t\t\t\t// put the previous custom type back\n\t\t\t\tawait this.sliceMachinePluginRunner?.callHook(\"custom-type:update\", {\n\t\t\t\t\tmodel: previousCustomType,\n\t\t\t\t});\n\t\t\t\t// revert the content relationships updates\n\t\t\t\tawait crUpdateResult.rollback?.();\n\n\t\t\t\treturn { errors: crUpdateResult.errors };\n\t\t\t}\n\t\t}\n\n\t\treturn { errors: [] };\n\t}\n\n\tasync renameCustomType(\n\t\targs: CustomTypeRenameHookData,\n\t): Promise<OnlyHookErrors<CallHookReturnType<CustomTypeRenameHook>>> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:rename\",\n\t\t\targs,\n\t\t);\n\n\t\treturn {\n\t\t\terrors: hookResult.errors,\n\t\t};\n\t}\n\n\tasync deleteCustomType(\n\t\targs: CustomTypesMachineManagerDeleteCustomTypeArgs,\n\t): Promise<CustomTypesMachineManagerDeleteCustomTypeReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst { model, errors: readCustomTypeErrors } = await this.readCustomType({\n\t\t\tid: args.id,\n\t\t});\n\n\t\tif (model) {\n\t\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\t\"custom-type:delete\",\n\t\t\t\t{ model },\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\terrors: hookResult.errors,\n\t\t\t};\n\t\t} else {\n\t\t\treturn {\n\t\t\t\terrors: readCustomTypeErrors,\n\t\t\t};\n\t\t}\n\t}\n\n\tasync pushCustomType(\n\t\targs: SliceMachineManagerPushCustomTypeArgs,\n\t): Promise<void> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst authenticationToken = await this.user.getAuthenticationToken();\n\t\tconst repositoryName = await this.project.getResolvedRepositoryName();\n\n\t\t// TODO: Handle errors\n\t\tconst { model } = await this.readCustomType({ id: args.id });\n\n\t\tif (model) {\n\t\t\t// TODO: Create a single shared client.\n\t\t\tconst client = prismicCustomTypesClient.createClient({\n\t\t\t\tendpoint: API_ENDPOINTS.PrismicModels,\n\t\t\t\trepositoryName,\n\t\t\t\ttoken: authenticationToken,\n\t\t\t\tfetch,\n\t\t\t\tfetchOptions: {\n\t\t\t\t\theaders: {\n\t\t\t\t\t\t\"User-Agent\": args.userAgent || SLICE_MACHINE_USER_AGENT,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t});\n\n\t\t\ttry {\n\t\t\t\t// Check if Custom Type already exists on the repository.\n\t\t\t\tawait client.getCustomTypeByID(args.id);\n\n\t\t\t\t// If it exists on the repository, update it.\n\t\t\t\tawait client.updateCustomType(model);\n\t\t\t} catch (error) {\n\t\t\t\tif (error instanceof prismicCustomTypesClient.NotFoundError) {\n\t\t\t\t\t// If it doesn't exist on the repository, insert it.\n\t\t\t\t\tawait client.insertCustomType(model);\n\t\t\t\t} else if (error instanceof prismicCustomTypesClient.ForbiddenError) {\n\t\t\t\t\tthrow new UnauthorizedError(\n\t\t\t\t\t\t\"You do not have access to push types to this Prismic repository.\",\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcause: error,\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// TODO: Remove\n\tasync readCustomTypeMocksConfig(\n\t\targs: SliceMachineManagerReadCustomTypeMocksConfigArgs,\n\t): Promise<SliceMachineManagerReadCustomTypeMocksConfigArgsReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:asset:read\",\n\t\t\t{\n\t\t\t\tcustomTypeID: args.customTypeID,\n\t\t\t\tassetID: \"mocks.config.json\",\n\t\t\t},\n\t\t);\n\t\tconst data = hookResult.data[0]?.data;\n\n\t\t// TODO: Validate the returned data.\n\n\t\tif (data) {\n\t\t\treturn {\n\t\t\t\tmocksConfig: JSON.parse(data.toString()),\n\t\t\t\terrors: hookResult.errors,\n\t\t\t};\n\t\t} else {\n\t\t\treturn {\n\t\t\t\tmocksConfig: undefined,\n\t\t\t\terrors: hookResult.errors,\n\t\t\t};\n\t\t}\n\t}\n\n\t// TODO: Remove\n\tasync updateCustomTypeMocksConfig(\n\t\targs: SliceMachineManagerUpdateCustomTypeMocksConfigArgs,\n\t): Promise<SliceMachineManagerUpdateCustomTypeMocksConfigArgsReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:asset:update\",\n\t\t\t{\n\t\t\t\tcustomTypeID: args.customTypeID,\n\t\t\t\tasset: {\n\t\t\t\t\tid: \"mocks.config.json\",\n\t\t\t\t\tdata: Buffer.from(JSON.stringify(args.mocksConfig, null, \"\\t\")),\n\t\t\t\t},\n\t\t\t},\n\t\t);\n\n\t\treturn {\n\t\t\terrors: hookResult.errors,\n\t\t};\n\t}\n\n\tasync fetchRemoteCustomTypes(): Promise<CustomType[]> {\n\t\tconst authenticationToken = await this.user.getAuthenticationToken();\n\t\tconst repositoryName = await this.project.getResolvedRepositoryName();\n\n\t\tconst client = prismicCustomTypesClient.createClient({\n\t\t\tendpoint: API_ENDPOINTS.PrismicModels,\n\t\t\trepositoryName,\n\t\t\ttoken: authenticationToken,\n\t\t\tfetch,\n\t\t\tfetchOptions: {\n\t\t\t\theaders: {\n\t\t\t\t\t\"User-Agent\": SLICE_MACHINE_USER_AGENT,\n\t\t\t\t},\n\t\t\t},\n\t\t});\n\n\t\treturn await client.getAllCustomTypes();\n\t}\n\n\tasync inferSlice(\n\t\targs: { imageUrl: string } & (\n\t\t\t| { source: \"upload\" }\n\t\t\t| { source: \"figma\"; libraryID: string }\n\t\t),\n\t): Promise<InferSliceResponse> {\n\t\tconst { source, imageUrl } = args;\n\t\tconst authToken = await this.user.getAuthenticationToken();\n\t\tconst repository = await this.project.getResolvedRepositoryName();\n\n\t\tif (source === \"figma\") {\n\t\t\tconst { libraryID } = args;\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.log(`inferSlice started`);\n\t\t\tconst startTime = Date.now();\n\n\t\t\tlet tmpDir: string | undefined;\n\t\t\ttry {\n\t\t\t\tconst config = await this.project.getSliceMachineConfig();\n\n\t\t\t\tlet framework:\n\t\t\t\t\t| { type: \"nextjs\" | \"nuxt\" | \"sveltekit\"; label: string }\n\t\t\t\t\t| undefined;\n\t\t\t\tif (config.adapter === \"@slicemachine/adapter-next\") {\n\t\t\t\t\tframework = { type: \"nextjs\", label: \"Next.js (React)\" };\n\t\t\t\t} else if (\n\t\t\t\t\tconfig.adapter === \"@slicemachine/adapter-nuxt\" ||\n\t\t\t\t\tconfig.adapter === \"@slicemachine/adapter-nuxt2\"\n\t\t\t\t) {\n\t\t\t\t\tframework = { type: \"nuxt\", label: \"Nuxt (Vue)\" };\n\t\t\t\t} else if (config.adapter === \"@slicemachine/adapter-sveltekit\") {\n\t\t\t\t\tframework = { type: \"sveltekit\", label: \"SvelteKit (Svelte)\" };\n\t\t\t\t}\n\n\t\t\t\tif (!framework) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\"Could not determine framework from Slice Machine config.\",\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tlet frameworkFileExtension: string | undefined;\n\t\t\t\tif (framework.type === \"nextjs\") {\n\t\t\t\t\tframeworkFileExtension = \"tsx\";\n\t\t\t\t} else if (framework.type === \"nuxt\") {\n\t\t\t\t\tframeworkFileExtension = \"vue\";\n\t\t\t\t} else if (framework.type === \"sveltekit\") {\n\t\t\t\t\tframeworkFileExtension = \"svelte\";\n\t\t\t\t}\n\n\t\t\t\tif (!frameworkFileExtension) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\"Could not determine framework from Slice Machine config.\",\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tconst projectRoot = await this.project.getRoot();\n\t\t\t\tconst libraryAbsPath = path.join(projectRoot, libraryID);\n\n\t\t\t\ttmpDir = await mkdtemp(\n\t\t\t\t\tpath.join(tmpdir(), \"slice-machine-infer-slice-tmp-\"),\n\t\t\t\t);\n\t\t\t\tconst tmpImagePath = path.join(tmpDir, `${randomUUID()}.png`);\n\t\t\t\tconst response = await fetch(imageUrl);\n\t\t\t\tif (!response.ok) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Failed to download image: ${response.status} ${response.statusText}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tawait writeFile(\n\t\t\t\t\ttmpImagePath,\n\t\t\t\t\tBuffer.from(await response.arrayBuffer()),\n\t\t\t\t);\n\n\t\t\t\tconst queries = queryClaude({\n\t\t\t\t\tprompt: `CRITICAL INSTRUCTIONS - READ FIRST:\n- You MUST start immediately with Step 1.1. DO NOT read, analyze, or explore any project files first.\n- Work step-by-step through the numbered tasks below.\n- DO NOT present any summary, explanation, or completion message after finishing.\n- DO NOT create TODO lists while performing tasks.\n- Keep responses minimal - only show necessary tool calls and brief progress notes.\n\n# CONTEXT \n\nThe user wants to build a new Prismic Slice based on a design image they provided.\nYour goal is to analyze the design image and generate the JSON model data and boilerplate code for the slice following Prismic requirements.\n\nYou will work under the slice library at <slice_library_path>, where all the slices are stored.\n\n# AVAILABLE RESOURCES\n\n<design_image_path>\n${tmpImagePath}\n</design_image_path>\n\n<slice_library_path>\n${libraryAbsPath}\n</slice_library_path>\n\n<framework>\n${framework.label}\n</framework>\n\n# AVAILABLE TOOLS\n\nYou have access to specialized Prismic MCP tools for this task:\n\n<tool name=\"mcp__prismic__how_to_model_slice\">\n<description>\nProvides detailed guidance on creating Prismic slice models, including field types, naming conventions, and best practices.\n</description>\n<when_to_use>\nCall this tool in Step 2.1 to learn how to structure the slice model data for the design you analysed.\n</when_to_use>\n</tool>\n\n<tool name=\"mcp__prismic__how_to_code_slice\">\n<description>\nProvides guidance on implementing Prismic slice components, including how to use Prismic field components, props structure, and best practices.\n</description>\n<when_to_use>\nCall this tool in Step 2.1 to learn how to properly structure the slice component with Prismic fields.\n</when_to_use>\n</tool>\n\n<tool name=\"mcp__prismic__save_slice_data\">\n<description>\nValidates and saves the slice model data to model.json. This is the ONLY way to create the model file.\n</description>\n<when_to_use>\nCall this tool in Step 2.3 after you have built the complete slice model structure in memory.\n</when_to_use>\n</tool>\n\n# TASK REQUIREMENTS\n\n## Step 1: Gather information from the design image\n1.1. Analyse the design image at <design_image_path>.\n1.2. Identify all elements in the image that should be dynamically editable (e.g., headings, paragraphs, images, links, buttons, etc.).\n1.3. List the slice directories under <slice_library_path>.\n1.4. Come up with a unique name for the new slice based on the content of the image and the slice directories.\n\n## Step 2: Model the Prismic slice\n2.1. Call mcp__prismic__how_to_model_slice to learn how to structure the model for this design.\n- Make sure the name you use for the new slice does not yet exist in the slice library at <slice_library_path>. If it does, use a different name.\n2.2. Build the complete slice JSON model data in memory based on the guidance received and the information extracted from the image.\n2.3. Call mcp__prismic__save_slice_data to save the model (DO NOT manually write model.json) in the slice library at <slice_library_path>.\n\n## Step 3: Code a boilerplate slice component based on the model\n3.1. Call mcp__prismic__how_to_code_slice to learn how to properly structure the slice component with Prismic fields.\n3.2. Update the slice component code at <slice_library_path>/index.${frameworkFileExtension}, replacing the placeholder code with boilerplate code with the following requirements:\n- Must NOT be based on existing slices or components from the codebase.\n- Must render all the Prismic components to display the fields of the slice model created at <slice_model_path>.\n- Must be a valid ${framework.label} component.\n- Must NOT have any styling/CSS. No inlines styles or classNames. Just the skeleton component structure.\n- Must NOT use any other custom component or functions from the user's codebase.\n- Avoid creating unnecessary wrapper elements, like if they only wrap a single component (e.g., <div><PrismicRichText /></div>).\n\n## Step 4: Present the newly created slice path\n4.1. Present the path to the newly created slice in the following format: <new_slice_path>${libraryAbsPath}/MyNewSlice</new_slice_path>.\n- \"MyNewSlice\" must be the name of the directory of the newly created slice.\n\n# EXAMPLE OF CORRECT EXECUTION\n\n<example>\nAssistant: Step 1.1: Analysing design image...\n[reads <design_image_path>]\n\nStep 1.2: Identifying editable content elements...\n[identifies: title field, description field, buttonText field, buttonLink field, backgroundImage field]\n\nStep 1.3: Listing slice directories under <slice_library_path>...\n[lists slice directories: Hero, Hero2, Hero3]\n\nStep 1.4: Coming up with a unique name for the new slice...\n[comes up with a unique name for the new slice: Hero4]\n\nStep 2.1: Getting Prismic modeling guidance...\n[calls mcp__prismic__how_to_model_slice]\n\nStep 2.2: Building slice model based on guidance and the information extracted...\n[creates model with title field, description field, buttonText field, buttonLink field, backgroundImage field]\n\nStep 2.3: Saving slice model...\n[calls mcp__prismic__save_slice_data]\n\nStep 3.1: Learning Prismic slice coding requirements...\n[calls mcp__prismic__how_to_code_slice]\n\nStep 3.2: Coding boilerplate slice component based on the model...\n[updates component with Prismic field components, no styling, no other components]\n\nStep 4.1: Presenting the path to the newly created slice...\n[presents <new_slice_path>${path.join(\n\t\t\t\t\t\tlibraryAbsPath,\n\t\t\t\t\t\t\"MyNewSlice\",\n\t\t\t\t\t)}</new_slice_path>]\n\n# DELIVERABLES\n- Slice model saved to <slice_library_path>/model.json using mcp__prismic__save_slice_data\n- Slice component at <slice_library_path>/index.${frameworkFileExtension} updated with boilerplate code\n- New slice path presented in the format mentioned in Step 3.1\n\nYOU ARE NOT FINISHED UNTIL YOU HAVE THESE DELIVERABLES.\n\n---\n\nFINAL REMINDERS:\n- You MUST use mcp__prismic__save_slice_data to save the model\n- You MUST call mcp__prismic__how_to_code_slice in Step 3.1\n- DO NOT ATTEMPT TO BUILD THE APPLICATION\n- START IMMEDIATELY WITH STEP 1.1 - NO PRELIMINARY ANALYSIS;`,\n\t\t\t\t\toptions: {\n\t\t\t\t\t\tcwd: libraryAbsPath,\n\t\t\t\t\t\tstderr: (data) => console.error(data),\n\t\t\t\t\t\tmodel: \"claude-haiku-4-5\",\n\t\t\t\t\t\tpermissionMode: \"bypassPermissions\",\n\t\t\t\t\t\tallowedTools: [\n\t\t\t\t\t\t\t\"Bash\",\n\t\t\t\t\t\t\t\"Read\",\n\t\t\t\t\t\t\t\"FileSearch\",\n\t\t\t\t\t\t\t\"Grep\",\n\t\t\t\t\t\t\t\"Glob\",\n\t\t\t\t\t\t\t\"Task\",\n\t\t\t\t\t\t\t\"Edit\",\n\t\t\t\t\t\t\t\"Write\",\n\t\t\t\t\t\t\t\"MultiEdit\",\n\t\t\t\t\t\t\t\"mcp__prismic__how_to_model_slice\",\n\t\t\t\t\t\t\t\"mcp__prismic__how_to_code_slice\",\n\t\t\t\t\t\t\t\"mcp__prismic__save_slice_data\",\n\t\t\t\t\t\t],\n\t\t\t\t\t\tdisallowedTools: [\n\t\t\t\t\t\t\t`Edit(**/model.json)`,\n\t\t\t\t\t\t\t`Write(**/model.json)`,\n\t\t\t\t\t\t\t\"Edit(**/mocks.json)\",\n\t\t\t\t\t\t\t\"Write(**/mocks.json)\",\n\t\t\t\t\t\t],\n\t\t\t\t\t\tenv: {\n\t\t\t\t\t\t\t...process.env,\n\t\t\t\t\t\t\tANTHROPIC_BASE_URL: API_ENDPOINTS.LlmProxyTypeService,\n\t\t\t\t\t\t\tANTHROPIC_CUSTOM_HEADERS:\n\t\t\t\t\t\t\t\t`x-prismic-token: ${authToken}\\n` +\n\t\t\t\t\t\t\t\t`x-prismic-repository: ${repository}\\n`,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tmcpServers: {\n\t\t\t\t\t\t\tprismic: {\n\t\t\t\t\t\t\t\ttype: \"stdio\",\n\t\t\t\t\t\t\t\tcommand: \"npx\",\n\t\t\t\t\t\t\t\targs: [\"-y\", \"@prismicio/mcp-server@0.0.20-alpha.6\"],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t});\n\n\t\t\t\tlet newSliceAbsPath: string | undefined;\n\n\t\t\t\tfor await (const query of queries) {\n\t\t\t\t\tswitch (query.type) {\n\t\t\t\t\t\tcase \"result\":\n\t\t\t\t\t\t\tif (query.subtype === \"success\") {\n\t\t\t\t\t\t\t\tnewSliceAbsPath = query.result.match(\n\t\t\t\t\t\t\t\t\t/<new_slice_path>(.*)<\\/new_slice_path>/s,\n\t\t\t\t\t\t\t\t)?.[1];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (!newSliceAbsPath) {\n\t\t\t\t\tthrow new Error(\"Could not find path for the newly created slice.\");\n\t\t\t\t}\n\n\t\t\t\tconst model = await readFile(\n\t\t\t\t\tpath.join(newSliceAbsPath, \"model.json\"),\n\t\t\t\t\t\"utf8\",\n\t\t\t\t);\n\n\t\t\t\tif (!model) {\n\t\t\t\t\tthrow new Error(\"Could not find model for the newly created slice.\");\n\t\t\t\t}\n\n\t\t\t\t// move the screenshot image to the new slice directory\n\t\t\t\tawait rename(\n\t\t\t\t\ttmpImagePath,\n\t\t\t\t\tpath.join(newSliceAbsPath, \"screenshot-default.png\"),\n\t\t\t\t);\n\t\t\t\tawait rm(tmpDir, { recursive: true });\n\n\t\t\t\tconst elapsedTimeSeconds = (Date.now() - startTime) / 1000;\n\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\tconsole.log(`inferSlice took ${elapsedTimeSeconds}s`);\n\n\t\t\t\treturn InferSliceResponse.parse({ slice: JSON.parse(model) });\n\t\t\t} catch (error) {\n\t\t\t\tif (tmpDir && existsSync(tmpDir)) {\n\t\t\t\t\tawait rm(tmpDir, { recursive: true });\n\t\t\t\t}\n\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t} else {\n\t\t\tconst headers = {\n\t\t\t\tAuthorization: `Bearer ${authToken}`,\n\t\t\t};\n\n\t\t\tconst searchParams = new URLSearchParams({\n\t\t\t\trepository,\n\t\t\t});\n\n\t\t\tconst url = new URL(\"./slices/infer\", API_ENDPOINTS.CustomTypeService);\n\t\t\turl.search = searchParams.toString();\n\n\t\t\tconst response = await fetch(url.toString(), {\n\t\t\t\tmethod: \"POST\",\n\t\t\t\theaders: headers,\n\t\t\t\tbody: JSON.stringify({ imageUrl }),\n\t\t\t});\n\n\t\t\tif (!response.ok) {\n\t\t\t\tthrow new Error(`Failed to infer slice: ${response.statusText}`);\n\t\t\t}\n\n\t\t\tconst json = await response.json();\n\n\t\t\treturn InferSliceResponse.parse(json);\n\t\t}\n\t}\n}\n\ntype InferSliceResponse = z.infer<typeof InferSliceResponse>;\n\nconst InferSliceResponse = z.object({\n\tslice: z.custom().transform((value, ctx) => {\n\t\tconst result = SharedSlice.decode(value);\n\t\tif (result._tag === \"Right\") {\n\t\t\treturn result.right;\n\t\t}\n\t\tctx.addIssue({\n\t\t\tcode: z.ZodIssueCode.custom,\n\t\t\tmessage: `Invalid shared slice: ${JSON.stringify(value, null, 2)}`,\n\t\t});\n\n\t\treturn z.NEVER;\n\t}),\n\tlangSmithUrl: z.string().url().optional(),\n});\n\nfunction updateCRCustomType(\n\targs: { customType: LinkCustomType } & CustomTypeFieldIdChangedMeta,\n): LinkCustomType {\n\tconst previousPath = getPathIds(args.previousPath);\n\tconst newPath = getPathIds(args.newPath);\n\n\tif (!previousPath.customTypeId || !newPath.customTypeId) {\n\t\tthrow new Error(\n\t\t\t`Could not find a customtype id in previousPath (${args.previousPath.join(\n\t\t\t\t\".\",\n\t\t\t)}) and/or newPath (${args.newPath.join(\n\t\t\t\t\".\",\n\t\t\t)}), which should not be possible.`,\n\t\t);\n\t}\n\n\tif (!previousPath.fieldId || !newPath.fieldId) {\n\t\tthrow new Error(\n\t\t\t`Could not find a field id in previousPath (${args.previousPath.join(\n\t\t\t\t\".\",\n\t\t\t)}) and/or newPath (${args.newPath.join(\n\t\t\t\t\".\",\n\t\t\t)}), which should not be possible.`,\n\t\t);\n\t}\n\n\tconst customType = shallowCloneIfObject(args.customType);\n\n\tif (typeof customType === \"string\") {\n\t\t// Legacy format support, we don't have anything to update here.\n\t\treturn customType;\n\t}\n\n\tconst matchedCustomTypeId = customType.id === previousPath.customTypeId;\n\n\treturn {\n\t\t...customType,\n\t\tfields: customType.fields.map((fieldArg) => {\n\t\t\tconst customTypeField = shallowCloneIfObject(fieldArg);\n\n\t\t\t// Regular field\n\t\t\tif (typeof customTypeField === \"string\") {\n\t\t\t\tif (\n\t\t\t\t\tmatchedCustomTypeId &&\n\t\t\t\t\tcustomTypeField === previousPath.fieldId &&\n\t\t\t\t\tcustomTypeField !== newPath.fieldId\n\t\t\t\t) {\n\t\t\t\t\t// The id of the field has changed.\n\t\t\t\t\treturn newPath.fieldId;\n\t\t\t\t}\n\n\t\t\t\treturn customTypeField;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tmatchedCustomTypeId &&\n\t\t\t\tcustomTypeField.id === previousPath.fieldId &&\n\t\t\t\tcustomTypeField.id !== newPath.fieldId\n\t\t\t) {\n\t\t\t\t// The id of the field has changed. We don't exit return because there\n\t\t\t\t// might be other fields further down in nested custom types or groups\n\t\t\t\t// that need to be updated.\n\t\t\t\tcustomTypeField.id = newPath.fieldId;\n\t\t\t}\n\n\t\t\t// Group field\n\t\t\tif (\"fields\" in customTypeField) {\n\t\t\t\tif (\n\t\t\t\t\t!previousPath.groupId &&\n\t\t\t\t\t!newPath.groupId &&\n\t\t\t\t\tcustomTypeField.id === previousPath.fieldId &&\n\t\t\t\t\tcustomTypeField.id !== newPath.fieldId\n\t\t\t\t) {\n\t\t\t\t\t// Only the id of the group has changed. Group id is not defined, so\n\t\t\t\t\t// we can return early.\n\t\t\t\t\treturn newPath.fieldId;\n\t\t\t\t}\n\n\t\t\t\tconst matchedGroupId = customTypeField.id === previousPath.groupId;\n\n\t\t\t\tif (\n\t\t\t\t\tpreviousPath.groupId &&\n\t\t\t\t\tnewPath.groupId &&\n\t\t\t\t\tmatchedGroupId &&\n\t\t\t\t\tcustomTypeField.id !== newPath.groupId\n\t\t\t\t) {\n\t\t\t\t\t// The id of the group field has changed, so we update it. We don't\n\t\t\t\t\t// return because there are group fields that may need to be updated.\n\t\t\t\t\tcustomTypeField.id = newPath.groupId;\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\t...customTypeField,\n\t\t\t\t\tfields: customTypeField.fields.map((groupFieldArg) => {\n\t\t\t\t\t\tconst groupField = shallowCloneIfObject(groupFieldArg);\n\n\t\t\t\t\t\t// Regular field inside a group field\n\t\t\t\t\t\tif (typeof groupField === \"string\") {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tmatchedGroupId &&\n\t\t\t\t\t\t\t\tgroupField === previousPath.fieldId &&\n\t\t\t\t\t\t\t\tgroupField !== newPath.fieldId\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t// The id of the field inside the group has changed.\n\t\t\t\t\t\t\t\treturn newPath.fieldId;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\treturn groupField;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Content relationship field inside a group field\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...groupField,\n\t\t\t\t\t\t\tfields: updateContentRelationshipFields({\n\t\t\t\t\t\t\t\tcustomtypes: groupField.customtypes,\n\t\t\t\t\t\t\t\tpreviousPath,\n\t\t\t\t\t\t\t\tnewPath,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t};\n\t\t\t\t\t}),\n\t\t\t\t};\n\t\t\t}\n\n\t\t\t// Content relationship field\n\t\t\treturn {\n\t\t\t\t...customTypeField,\n\t\t\t\tcustomtypes: updateContentRelationshipFields({\n\t\t\t\t\tcustomtypes: customTypeField.customtypes,\n\t\t\t\t\tpreviousPath,\n\t\t\t\t\tnewPath,\n\t\t\t\t}),\n\t\t\t};\n\t\t}),\n\t};\n}\n\nfunction updateContentRelationshipFields(args: {\n\tcustomtypes: readonly (\n\t\t| string\n\t\t| {\n\t\t\t\tid: string;\n\t\t\t\tfields: readonly (string | { id: string; fields: readonly string[] })[];\n\t\t }\n\t)[];\n\tpreviousPath: CrUpdatePathIds;\n\tnewPath: CrUpdatePathIds;\n}) {\n\tconst { customtypes, previousPath, newPath } = args;\n\n\treturn customtypes.map((nestedCtArg) => {\n\t\tconst nestedCt = shallowCloneIfObject(nestedCtArg);\n\n\t\tif (\n\t\t\ttypeof nestedCt === \"string\" ||\n\t\t\t// Since we are entering a new custom type, if the previous id\n\t\t\t// doesn't match, we can return early, because it's not the\n\t\t\t// custom type we are looking for.\n\t\t\tnestedCt.id !== previousPath.customTypeId\n\t\t) {\n\t\t\treturn nestedCt;\n\t\t}\n\n\t\treturn {\n\t\t\t...nestedCt,\n\t\t\tfields: nestedCt.fields.map((nestedCtFieldArg) => {\n\t\t\t\tconst nestedCtField = shallowCloneIfObject(nestedCtFieldArg);\n\n\t\t\t\t// Regular field\n\t\t\t\tif (typeof nestedCtField === \"string\") {\n\t\t\t\t\tif (\n\t\t\t\t\t\tnestedCtField === previousPath.fieldId &&\n\t\t\t\t\t\tnestedCtField !== newPath.fieldId\n\t\t\t\t\t) {\n\t\t\t\t\t\t// The id of the field has changed.\n\t\t\t\t\t\treturn newPath.fieldId;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn nestedCtField;\n\t\t\t\t}\n\n\t\t\t\t// Group field\n\n\t\t\t\tif (\n\t\t\t\t\tnestedCtField.id === previousPath.fieldId &&\n\t\t\t\t\tnestedCtField.id !== newPath.fieldId\n\t\t\t\t) {\n\t\t\t\t\t// The id of the field has changed.\n\t\t\t\t\tnestedCtField.id = newPath.fieldId;\n\t\t\t\t}\n\n\t\t\t\t// Further down the path, the field can only be a group field. So if we have\n\t\t\t\t// no group id defined, no need to continue.\n\t\t\t\tif (\n\t\t\t\t\t!previousPath.groupId ||\n\t\t\t\t\t!newPath.groupId ||\n\t\t\t\t\tnestedCtField.id !== previousPath.groupId\n\t\t\t\t) {\n\t\t\t\t\treturn nestedCtField;\n\t\t\t\t}\n\n\t\t\t\tif (nestedCtField.id !== newPath.groupId) {\n\t\t\t\t\t// The id of the group has changed.\n\t\t\t\t\tnestedCtField.id = newPath.groupId;\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\t...nestedCtField,\n\t\t\t\t\tfields: nestedCtField.fields.map((nestedCtGroupFieldId) => {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tnestedCtGroupFieldId === previousPath.fieldId &&\n\t\t\t\t\t\t\tnestedCtGroupFieldId !== newPath.fieldId\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t// The id of the field inside the group has changed.\n\t\t\t\t\t\t\treturn newPath.fieldId;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn nestedCtGroupFieldId;\n\t\t\t\t\t}),\n\t\t\t\t};\n\t\t\t}),\n\t\t};\n\t});\n}\n\n/**\n * Update the Content Relationship API IDs of a single field. The change is\n * determined by the `previousPath` and `newPath` properties.\n */\nfunction updateFieldContentRelationships<\n\tT extends UID | NestableWidget | Group | NestedGroup,\n>(args: { field: T } & CustomTypeFieldIdChangedMeta): T {\n\tconst { field, ...updateMeta } = args;\n\tif (\n\t\tfield.type !== \"Link\" ||\n\t\tfield.config?.select !== \"document\" ||\n\t\t!field.config?.customtypes\n\t) {\n\t\t// not a content relationship field\n\t\treturn field;\n\t}\n\n\tconst newCustomTypes = field.config.customtypes.map((customType) => {\n\t\treturn updateCRCustomType({ ...updateMeta, customType });\n\t});\n\n\treturn {\n\t\t...field,\n\t\tconfig: { ...field.config, customtypes: newCustomTypes },\n\t};\n}\n\nexport function updateCustomTypeContentRelationships(\n\targs: {\n\t\tmodels: { model: CustomType }[];\n\t\tonUpdate: (model: { previousModel: CustomType; model: CustomType }) => void;\n\t} & CustomTypeFieldIdChangedMeta,\n): void {\n\tconst { models, previousPath, newPath, onUpdate } = args;\n\n\tfor (const { model: customType } of models) {\n\t\tconst updatedCustomType = traverseCustomType({\n\t\t\tcustomType,\n\t\t\tonField: ({ field }) => {\n\t\t\t\treturn updateFieldContentRelationships({\n\t\t\t\t\tfield,\n\t\t\t\t\tpreviousPath,\n\t\t\t\t\tnewPath,\n\t\t\t\t});\n\t\t\t},\n\t\t});\n\n\t\tif (!isEqualModel(customType, updatedCustomType)) {\n\t\t\tonUpdate({ model: updatedCustomType, previousModel: customType });\n\t\t}\n\t}\n}\n\nexport function updateSharedSliceContentRelationships(\n\targs: {\n\t\tmodels: { model: SharedSlice }[];\n\t\tonUpdate: (model: {\n\t\t\tpreviousModel: SharedSlice;\n\t\t\tmodel: SharedSlice;\n\t\t}) => void;\n\t} & CustomTypeFieldIdChangedMeta,\n): void {\n\tconst { models, previousPath, newPath, onUpdate } = args;\n\n\tfor (const { model: slice } of models) {\n\t\tconst updateSlice = traverseSharedSlice({\n\t\t\tpath: [],\n\t\t\tslice,\n\t\t\tonField: ({ field }) => {\n\t\t\t\treturn updateFieldContentRelationships({\n\t\t\t\t\tfield,\n\t\t\t\t\tpreviousPath,\n\t\t\t\t\tnewPath,\n\t\t\t\t});\n\t\t\t},\n\t\t});\n\n\t\tif (!isEqualModel(slice, updateSlice)) {\n\t\t\tonUpdate({ model: updateSlice, previousModel: slice });\n\t\t}\n\t}\n}\n\ninterface CrUpdatePathIds {\n\tcustomTypeId: string;\n\tgroupId: string | undefined;\n\tfieldId: string;\n}\n\nfunction getPathIds(path: PathWithCustomType): CrUpdatePathIds {\n\tif (path.length < 2) {\n\t\tthrow new Error(\n\t\t\t`Unexpected path length ${\n\t\t\t\tpath.length\n\t\t\t}. Expected at least 2 segments (got: ${path.join(\".\")}).`,\n\t\t);\n\t}\n\n\tconst [customTypeId, groupOrFieldId, fieldId] = path;\n\n\treturn {\n\t\tcustomTypeId,\n\t\t/**\n\t\t * Id of a changed group. If it's defined, it means that a group or a field\n\t\t * inside a group had its API ID renamed. It's defined when the path has a\n\t\t * third element (e.g. `[\"customtypeA\", \"groupA\", \"fieldA\"]`).\n\t\t */\n\t\tgroupId: fieldId ? groupOrFieldId : undefined,\n\t\tfieldId: fieldId || groupOrFieldId,\n\t};\n}\n\nfunction isEqualModel<T extends CustomType | SharedSlice>(\n\tmodelA: T,\n\tmodelB: T,\n): boolean {\n\treturn JSON.stringify(modelA) === JSON.stringify(modelB);\n}\n\nfunction shallowCloneIfObject<T>(value: T): T {\n\tif (typeof value === \"object\") {\n\t\treturn { ...value };\n\t}\n\n\treturn value;\n}\n"],"names":["BaseManager","assertPluginsInitialized","errors","decodeHookResult","t","CustomType","_a","prismicCustomTypesClient","API_ENDPOINTS","fetch","SLICE_MACHINE_USER_AGENT","UnauthorizedError","mkdtemp","tmpdir","randomUUID","writeFile","queryClaude","readFile","rename","rm","existsSync","z","SharedSlice","customtypes","traverseCustomType","traverseSharedSlice","path"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuIM,MAAO,2BAA2BA,YAAAA,YAAW;AAAA,EAClD,MAAM,wBAAqB;;AAC1BC,6BAAAA,yBAAyB,KAAK,wBAAwB;AAEtD,UAAM,aAAa,MAAM,KAAK,yBAAyB,SACtD,4BACA,MAAS;AAEV,UAAM,EAAE,MAAM,QAAAC,QAAA,IAAWC,iBAAAA,iBACxBC,aAAE,KAAK;AAAA,MACN,KAAKA,aAAE,MAAMA,aAAE,MAAM;AAAA,IAAA,CACrB,GACD,UAAU;AAGX,WAAO;AAAA,MACN,OAAK,UAAK,CAAC,MAAN,mBAAS,QAAO,CAAA;AAAA,MACrB,QAAAF;AAAA,IAAA;AAAA,EAEF;AAAA,EAEA,MAAM,mBACL,MAA+C;AAE/CD,6BAAAA,yBAAyB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AM,MAAM,KAAK,UAAU,MAAM;AACxD;AAEA,SAAS,qBAAwB,OAAQ;AACxC,MAAI,OAAO,UAAU,UAAU;AAC9B,WAAO,EAAE,GAAG,MAAA;AAAA,EACb;AAEA,SAAO;AACR;;;;"}
1
+ {"version":3,"file":"CustomTypesManager.cjs","sources":["../../../../src/managers/customTypes/CustomTypesManager.ts"],"sourcesContent":["import * as t from \"io-ts\";\nimport * as prismicCustomTypesClient from \"@prismicio/custom-types-client\";\nimport {\n\tCustomType,\n\tGroup,\n\tLinkConfig,\n\tNestableWidget,\n\tNestedGroup,\n\tSharedSlice,\n\tUID,\n\ttraverseCustomType,\n\ttraverseSharedSlice,\n} from \"@prismicio/types-internal/lib/customtypes\";\nimport {\n\tCallHookReturnType,\n\tCustomTypeCreateHook,\n\tCustomTypeCreateHookData,\n\tCustomTypeReadHookData,\n\tCustomTypeRenameHook,\n\tCustomTypeRenameHookData,\n\tCustomTypeUpdateHook,\n\tCustomTypeUpdateHookData,\n\tHookError,\n} from \"@slicemachine/plugin-kit\";\nimport { z } from \"zod\";\nimport { query as queryClaude } from \"@anthropic-ai/claude-agent-sdk\";\n\nimport { DecodeError } from \"../../lib/DecodeError\";\nimport { assertPluginsInitialized } from \"../../lib/assertPluginsInitialized\";\nimport { decodeHookResult } from \"../../lib/decodeHookResult\";\nimport fetch from \"../../lib/fetch\";\n\nimport { OnlyHookErrors } from \"../../types\";\nimport { API_ENDPOINTS } from \"../../constants/API_ENDPOINTS\";\nimport { SLICE_MACHINE_USER_AGENT } from \"../../constants/SLICE_MACHINE_USER_AGENT\";\nimport { UnauthorizedError } from \"../../errors\";\nimport { mkdtemp, readFile, rename, rm, writeFile } from \"fs/promises\";\nimport { tmpdir } from \"os\";\nimport path from \"path\";\nimport { randomUUID } from \"crypto\";\nimport { existsSync } from \"fs\";\n\nimport { BaseManager } from \"../BaseManager\";\nimport { CustomTypeFormat } from \"./types\";\n\ntype SliceMachineManagerReadCustomTypeLibraryReturnType = {\n\tids: string[];\n\terrors: (DecodeError | HookError)[];\n};\n\ntype CustomTypesManagerReadAllCustomTypesArgs = {\n\tformat: CustomTypeFormat;\n};\n\ntype SliceMachineManagerReadAllCustomTypeReturnType = {\n\tmodels: { model: CustomType }[];\n\terrors: (DecodeError | HookError)[];\n};\n\ntype SliceMachineManagerReadCustomTypeReturnType = {\n\tmodel: CustomType | undefined;\n\terrors: (DecodeError | HookError)[];\n};\n\ntype SliceMachineManagerPushCustomTypeArgs = {\n\tid: string;\n\tuserAgent?: string;\n};\n\ntype SliceMachineManagerReadCustomTypeMocksConfigArgs = {\n\tcustomTypeID: string;\n};\n\ntype SliceMachineManagerReadCustomTypeMocksConfigArgsReturnType = {\n\t// TODO\n\tmocksConfig?: Record<string, unknown>;\n\terrors: HookError[];\n};\n\ntype SliceMachineManagerUpdateCustomTypeMocksConfigArgs = {\n\tcustomTypeID: string;\n\t// TODO\n\tmocksConfig: Record<string, unknown>;\n};\n\n/** `[field]` or `[group, field]` – path **inside** the Custom Type */\ntype PathWithoutCustomType = [string] | [string, string];\n\ntype SliceMachineManagerUpdateCustomTypeFieldIdChanged = {\n\t/**\n\t * Previous path of the changed field, excluding the custom type id. Can be\n\t * used to identify the field that had an API ID rename (e.g. [\"fieldA\"] or\n\t * [\"groupA\", \"fieldA\"])\n\t */\n\tpreviousPath: PathWithoutCustomType;\n\t/**\n\t * New path of the changed field, excluding the custom type id. Can be used to\n\t * identify the field that had an API ID rename (e.g. [\"fieldB\"] or [\"groupA\",\n\t * \"fieldB\"])\n\t */\n\tnewPath: PathWithoutCustomType;\n};\n\ntype SliceMachineManagerUpdateCustomTypeArgs = CustomTypeUpdateHookData & {\n\tupdateMeta?: {\n\t\tfieldIdChanged?: SliceMachineManagerUpdateCustomTypeFieldIdChanged;\n\t};\n};\n\ntype SliceMachineManagerUpdateCustomTypeMocksConfigArgsReturnType = {\n\terrors: HookError[];\n};\n\ntype CustomTypesMachineManagerDeleteCustomTypeArgs = {\n\tid: string;\n};\n\ntype CustomTypesMachineManagerDeleteCustomTypeReturnType = {\n\terrors: (DecodeError | HookError)[];\n};\n\ntype CustomTypesMachineManagerUpdateCustomTypeReturnType = {\n\terrors: (DecodeError | HookError)[];\n};\n\n/** `[ct, field]` or `[ct, group, field]` – path **with** Custom Type ID */\ntype PathWithCustomType = [string, string] | [string, string, string];\n\ntype CustomTypeFieldIdChangedMeta = {\n\tpreviousPath: PathWithCustomType;\n\tnewPath: PathWithCustomType;\n};\n\ntype LinkCustomType = NonNullable<LinkConfig[\"customtypes\"]>[number];\n\nexport class CustomTypesManager extends BaseManager {\n\tasync readCustomTypeLibrary(): Promise<SliceMachineManagerReadCustomTypeLibraryReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type-library:read\",\n\t\t\tundefined,\n\t\t);\n\t\tconst { data, errors } = decodeHookResult(\n\t\t\tt.type({\n\t\t\t\tids: t.array(t.string),\n\t\t\t}),\n\t\t\thookResult,\n\t\t);\n\n\t\treturn {\n\t\t\tids: data[0]?.ids || [],\n\t\t\terrors,\n\t\t};\n\t}\n\n\tasync readAllCustomTypes(\n\t\targs?: CustomTypesManagerReadAllCustomTypesArgs,\n\t): Promise<SliceMachineManagerReadAllCustomTypeReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst res: SliceMachineManagerReadAllCustomTypeReturnType = {\n\t\t\tmodels: [],\n\t\t\terrors: [],\n\t\t};\n\n\t\tconst { ids, errors } = await this.readCustomTypeLibrary();\n\t\tres.errors = [...res.errors, ...errors];\n\n\t\tif (ids) {\n\t\t\tfor (const id of ids) {\n\t\t\t\tconst { model, errors } = await this.readCustomType({ id });\n\t\t\t\tres.errors = [...res.errors, ...errors];\n\n\t\t\t\tif (model && (!args || args.format === model.format)) {\n\t\t\t\t\tres.models.push({ model });\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn res;\n\t}\n\n\tasync createCustomType(\n\t\targs: CustomTypeCreateHookData,\n\t): Promise<OnlyHookErrors<CallHookReturnType<CustomTypeCreateHook>>> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:create\",\n\t\t\targs,\n\t\t);\n\n\t\treturn {\n\t\t\terrors: hookResult.errors,\n\t\t};\n\t}\n\n\tasync readCustomType(\n\t\targs: CustomTypeReadHookData,\n\t): Promise<SliceMachineManagerReadCustomTypeReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:read\",\n\t\t\targs,\n\t\t);\n\t\tconst { data, errors } = decodeHookResult(\n\t\t\tt.type({\n\t\t\t\tmodel: CustomType,\n\t\t\t}),\n\t\t\thookResult,\n\t\t);\n\n\t\treturn {\n\t\t\tmodel: data[0]?.model,\n\t\t\terrors,\n\t\t};\n\t}\n\n\t/**\n\t * Update the Content Relationship API IDs for all existing custom types and\n\t * slices. The change is determined by properties inside the `updateMeta`\n\t * property.\n\t */\n\tprivate async updateContentRelationships(\n\t\targs: {\n\t\t\tmodel: CustomType;\n\t\t} & SliceMachineManagerUpdateCustomTypeFieldIdChanged,\n\t): Promise<\n\t\tOnlyHookErrors<CallHookReturnType<CustomTypeUpdateHook>> & {\n\t\t\trollback?: () => Promise<void>;\n\t\t}\n\t> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst {\n\t\t\tmodel,\n\t\t\tpreviousPath: previousFieldPath,\n\t\t\tnewPath: newFieldPath,\n\t\t} = args;\n\n\t\tif (previousFieldPath.join(\".\") !== newFieldPath.join(\".\")) {\n\t\t\tconst { id: ctId } = model;\n\t\t\tconst previousPath: PathWithCustomType = [ctId, ...previousFieldPath];\n\t\t\tconst newPath: PathWithCustomType = [ctId, ...newFieldPath];\n\n\t\t\tconst crUpdates: {\n\t\t\t\tupdatePromise: Promise<{ errors: HookError[] }>;\n\t\t\t\trollback: () => void;\n\t\t\t}[] = [];\n\n\t\t\t// Find existing content relationships that link to the renamed field id in\n\t\t\t// any custom type and update them to use the new one.\n\t\t\tconst customTypes = await this.readAllCustomTypes();\n\n\t\t\tupdateCustomTypeContentRelationships({\n\t\t\t\tmodels: customTypes.models,\n\t\t\t\tonUpdate: ({ previousModel, model: updatedModel }) => {\n\t\t\t\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\t\t\t\tcrUpdates.push({\n\t\t\t\t\t\tupdatePromise: this.sliceMachinePluginRunner?.callHook(\n\t\t\t\t\t\t\t\"custom-type:update\",\n\t\t\t\t\t\t\t{ model: updatedModel },\n\t\t\t\t\t\t),\n\t\t\t\t\t\trollback: () => {\n\t\t\t\t\t\t\tthis.sliceMachinePluginRunner?.callHook(\"custom-type:update\", {\n\t\t\t\t\t\t\t\tmodel: previousModel,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t},\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\tpreviousPath,\n\t\t\t\tnewPath,\n\t\t\t});\n\n\t\t\t// Find existing slice with content relationships that link to the renamed\n\t\t\t// field id in all libraries and update them to use the new one.\n\t\t\tconst { libraries } = await this.slices.readAllSliceLibraries();\n\n\t\t\tfor (const library of libraries) {\n\t\t\t\tconst slices = await this.slices.readAllSlicesForLibrary({\n\t\t\t\t\tlibraryID: library.libraryID,\n\t\t\t\t});\n\n\t\t\t\tupdateSharedSliceContentRelationships({\n\t\t\t\t\tmodels: slices.models,\n\t\t\t\t\tonUpdate: ({ previousModel, model: updatedModel }) => {\n\t\t\t\t\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\t\t\t\t\tcrUpdates.push({\n\t\t\t\t\t\t\tupdatePromise: this.sliceMachinePluginRunner?.callHook(\n\t\t\t\t\t\t\t\t\"slice:update\",\n\t\t\t\t\t\t\t\t{ libraryID: library.libraryID, model: updatedModel },\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\trollback: () => {\n\t\t\t\t\t\t\t\tthis.sliceMachinePluginRunner?.callHook(\"slice:update\", {\n\t\t\t\t\t\t\t\t\tlibraryID: library.libraryID,\n\t\t\t\t\t\t\t\t\tmodel: previousModel,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t});\n\t\t\t\t\t},\n\t\t\t\t\tpreviousPath,\n\t\t\t\t\tnewPath,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// Process all the Content Relationship updates at once.\n\t\t\tconst crUpdatesResult = await Promise.all(\n\t\t\t\tcrUpdates.map((update) => update.updatePromise),\n\t\t\t);\n\n\t\t\tif (crUpdatesResult.some((result) => result.errors.length > 0)) {\n\t\t\t\treturn {\n\t\t\t\t\terrors: crUpdatesResult.flatMap((result) => result.errors),\n\t\t\t\t\trollback: async () => {\n\t\t\t\t\t\tawait Promise.all(crUpdates.map((update) => update.rollback()));\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\treturn { errors: [] };\n\t}\n\n\tasync updateCustomType(\n\t\targs: SliceMachineManagerUpdateCustomTypeArgs,\n\t): Promise<CustomTypesMachineManagerUpdateCustomTypeReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\t\tconst { model } = args;\n\t\tconst { fieldIdChanged } = args.updateMeta ?? {};\n\n\t\tlet previousCustomType: CustomType | undefined;\n\n\t\tif (fieldIdChanged) {\n\t\t\tconst customTypeRead = await this.readCustomType({ id: model.id });\n\n\t\t\tif (customTypeRead.errors.length > 0) {\n\t\t\t\treturn { errors: customTypeRead.errors };\n\t\t\t}\n\t\t\tif (!customTypeRead.model) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`readCustomType succeeded reading custom type ${model.id} but model is undefined.`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tpreviousCustomType = customTypeRead.model;\n\t\t}\n\n\t\tconst customTypeUpdateResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:update\",\n\t\t\t{ model },\n\t\t);\n\n\t\tif (customTypeUpdateResult.errors.length > 0) {\n\t\t\treturn { errors: customTypeUpdateResult.errors };\n\t\t}\n\n\t\tif (previousCustomType && fieldIdChanged) {\n\t\t\tconst crUpdateResult = await this.updateContentRelationships({\n\t\t\t\t...fieldIdChanged,\n\t\t\t\tmodel: previousCustomType,\n\t\t\t});\n\n\t\t\tif (crUpdateResult.errors.length > 0) {\n\t\t\t\t// put the previous custom type back\n\t\t\t\tawait this.sliceMachinePluginRunner?.callHook(\"custom-type:update\", {\n\t\t\t\t\tmodel: previousCustomType,\n\t\t\t\t});\n\t\t\t\t// revert the content relationships updates\n\t\t\t\tawait crUpdateResult.rollback?.();\n\n\t\t\t\treturn { errors: crUpdateResult.errors };\n\t\t\t}\n\t\t}\n\n\t\treturn { errors: [] };\n\t}\n\n\tasync renameCustomType(\n\t\targs: CustomTypeRenameHookData,\n\t): Promise<OnlyHookErrors<CallHookReturnType<CustomTypeRenameHook>>> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:rename\",\n\t\t\targs,\n\t\t);\n\n\t\treturn {\n\t\t\terrors: hookResult.errors,\n\t\t};\n\t}\n\n\tasync deleteCustomType(\n\t\targs: CustomTypesMachineManagerDeleteCustomTypeArgs,\n\t): Promise<CustomTypesMachineManagerDeleteCustomTypeReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst { model, errors: readCustomTypeErrors } = await this.readCustomType({\n\t\t\tid: args.id,\n\t\t});\n\n\t\tif (model) {\n\t\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\t\"custom-type:delete\",\n\t\t\t\t{ model },\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\terrors: hookResult.errors,\n\t\t\t};\n\t\t} else {\n\t\t\treturn {\n\t\t\t\terrors: readCustomTypeErrors,\n\t\t\t};\n\t\t}\n\t}\n\n\tasync pushCustomType(\n\t\targs: SliceMachineManagerPushCustomTypeArgs,\n\t): Promise<void> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst authenticationToken = await this.user.getAuthenticationToken();\n\t\tconst repositoryName = await this.project.getResolvedRepositoryName();\n\n\t\t// TODO: Handle errors\n\t\tconst { model } = await this.readCustomType({ id: args.id });\n\n\t\tif (model) {\n\t\t\t// TODO: Create a single shared client.\n\t\t\tconst client = prismicCustomTypesClient.createClient({\n\t\t\t\tendpoint: API_ENDPOINTS.PrismicModels,\n\t\t\t\trepositoryName,\n\t\t\t\ttoken: authenticationToken,\n\t\t\t\tfetch,\n\t\t\t\tfetchOptions: {\n\t\t\t\t\theaders: {\n\t\t\t\t\t\t\"User-Agent\": args.userAgent || SLICE_MACHINE_USER_AGENT,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t});\n\n\t\t\ttry {\n\t\t\t\t// Check if Custom Type already exists on the repository.\n\t\t\t\tawait client.getCustomTypeByID(args.id);\n\n\t\t\t\t// If it exists on the repository, update it.\n\t\t\t\tawait client.updateCustomType(model);\n\t\t\t} catch (error) {\n\t\t\t\tif (error instanceof prismicCustomTypesClient.NotFoundError) {\n\t\t\t\t\t// If it doesn't exist on the repository, insert it.\n\t\t\t\t\tawait client.insertCustomType(model);\n\t\t\t\t} else if (error instanceof prismicCustomTypesClient.ForbiddenError) {\n\t\t\t\t\tthrow new UnauthorizedError(\n\t\t\t\t\t\t\"You do not have access to push types to this Prismic repository.\",\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcause: error,\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// TODO: Remove\n\tasync readCustomTypeMocksConfig(\n\t\targs: SliceMachineManagerReadCustomTypeMocksConfigArgs,\n\t): Promise<SliceMachineManagerReadCustomTypeMocksConfigArgsReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:asset:read\",\n\t\t\t{\n\t\t\t\tcustomTypeID: args.customTypeID,\n\t\t\t\tassetID: \"mocks.config.json\",\n\t\t\t},\n\t\t);\n\t\tconst data = hookResult.data[0]?.data;\n\n\t\t// TODO: Validate the returned data.\n\n\t\tif (data) {\n\t\t\treturn {\n\t\t\t\tmocksConfig: JSON.parse(data.toString()),\n\t\t\t\terrors: hookResult.errors,\n\t\t\t};\n\t\t} else {\n\t\t\treturn {\n\t\t\t\tmocksConfig: undefined,\n\t\t\t\terrors: hookResult.errors,\n\t\t\t};\n\t\t}\n\t}\n\n\t// TODO: Remove\n\tasync updateCustomTypeMocksConfig(\n\t\targs: SliceMachineManagerUpdateCustomTypeMocksConfigArgs,\n\t): Promise<SliceMachineManagerUpdateCustomTypeMocksConfigArgsReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:asset:update\",\n\t\t\t{\n\t\t\t\tcustomTypeID: args.customTypeID,\n\t\t\t\tasset: {\n\t\t\t\t\tid: \"mocks.config.json\",\n\t\t\t\t\tdata: Buffer.from(JSON.stringify(args.mocksConfig, null, \"\\t\")),\n\t\t\t\t},\n\t\t\t},\n\t\t);\n\n\t\treturn {\n\t\t\terrors: hookResult.errors,\n\t\t};\n\t}\n\n\tasync fetchRemoteCustomTypes(): Promise<CustomType[]> {\n\t\tconst authenticationToken = await this.user.getAuthenticationToken();\n\t\tconst repositoryName = await this.project.getResolvedRepositoryName();\n\n\t\tconst client = prismicCustomTypesClient.createClient({\n\t\t\tendpoint: API_ENDPOINTS.PrismicModels,\n\t\t\trepositoryName,\n\t\t\ttoken: authenticationToken,\n\t\t\tfetch,\n\t\t\tfetchOptions: {\n\t\t\t\theaders: {\n\t\t\t\t\t\"User-Agent\": SLICE_MACHINE_USER_AGENT,\n\t\t\t\t},\n\t\t\t},\n\t\t});\n\n\t\treturn await client.getAllCustomTypes();\n\t}\n\n\tasync inferSlice(\n\t\targs: { imageUrl: string } & (\n\t\t\t| { source: \"upload\" }\n\t\t\t| { source: \"figma\"; libraryID: string }\n\t\t),\n\t): Promise<InferSliceResponse> {\n\t\tconst { source, imageUrl } = args;\n\n\t\tconst exp = await this.telemetry.getExperimentVariant(\"llm-proxy-access\");\n\t\tif (exp?.value !== \"on\") {\n\t\t\tthrow new Error(\"LLM proxy access is not enabled.\");\n\t\t}\n\t\tconst { llmProxyUrl } = z\n\t\t\t.object({ llmProxyUrl: z.string() })\n\t\t\t.parse(exp.payload);\n\n\t\tconst authToken = await this.user.getAuthenticationToken();\n\t\tconst repository = await this.project.getResolvedRepositoryName();\n\n\t\tif (source === \"figma\") {\n\t\t\tconst { libraryID } = args;\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.log(`inferSlice started`);\n\t\t\tconst startTime = Date.now();\n\n\t\t\tlet tmpDir: string | undefined;\n\t\t\ttry {\n\t\t\t\tconst config = await this.project.getSliceMachineConfig();\n\n\t\t\t\tlet framework:\n\t\t\t\t\t| { type: \"nextjs\" | \"nuxt\" | \"sveltekit\"; label: string }\n\t\t\t\t\t| undefined;\n\t\t\t\tif (config.adapter === \"@slicemachine/adapter-next\") {\n\t\t\t\t\tframework = { type: \"nextjs\", label: \"Next.js (React)\" };\n\t\t\t\t} else if (\n\t\t\t\t\tconfig.adapter === \"@slicemachine/adapter-nuxt\" ||\n\t\t\t\t\tconfig.adapter === \"@slicemachine/adapter-nuxt2\"\n\t\t\t\t) {\n\t\t\t\t\tframework = { type: \"nuxt\", label: \"Nuxt (Vue)\" };\n\t\t\t\t} else if (config.adapter === \"@slicemachine/adapter-sveltekit\") {\n\t\t\t\t\tframework = { type: \"sveltekit\", label: \"SvelteKit (Svelte)\" };\n\t\t\t\t}\n\n\t\t\t\tif (!framework) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\"Could not determine framework from Slice Machine config.\",\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tlet frameworkFileExtension: string | undefined;\n\t\t\t\tif (framework.type === \"nextjs\") {\n\t\t\t\t\tframeworkFileExtension = \"tsx\";\n\t\t\t\t} else if (framework.type === \"nuxt\") {\n\t\t\t\t\tframeworkFileExtension = \"vue\";\n\t\t\t\t} else if (framework.type === \"sveltekit\") {\n\t\t\t\t\tframeworkFileExtension = \"svelte\";\n\t\t\t\t}\n\n\t\t\t\tif (!frameworkFileExtension) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\"Could not determine framework from Slice Machine config.\",\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tconst projectRoot = await this.project.getRoot();\n\t\t\t\tconst libraryAbsPath = path.join(projectRoot, libraryID);\n\n\t\t\t\ttmpDir = await mkdtemp(\n\t\t\t\t\tpath.join(tmpdir(), \"slice-machine-infer-slice-tmp-\"),\n\t\t\t\t);\n\t\t\t\tconst tmpImagePath = path.join(tmpDir, `${randomUUID()}.png`);\n\t\t\t\tconst response = await fetch(imageUrl);\n\t\t\t\tif (!response.ok) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Failed to download image: ${response.status} ${response.statusText}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tawait writeFile(\n\t\t\t\t\ttmpImagePath,\n\t\t\t\t\tBuffer.from(await response.arrayBuffer()),\n\t\t\t\t);\n\n\t\t\t\tconst queries = queryClaude({\n\t\t\t\t\tprompt: `CRITICAL INSTRUCTIONS - READ FIRST:\n- You MUST start immediately with Step 1.1. DO NOT read, analyze, or explore any project files first.\n- Work step-by-step through the numbered tasks below.\n- DO NOT present any summary, explanation, or completion message after finishing.\n- DO NOT create TODO lists while performing tasks.\n- Keep responses minimal - only show necessary tool calls and brief progress notes.\n\n# CONTEXT \n\nThe user wants to build a new Prismic Slice based on a design image they provided.\nYour goal is to analyze the design image and generate the JSON model data and boilerplate code for the slice following Prismic requirements.\n\nYou will work under the slice library at <slice_library_path>, where all the slices are stored.\n\n# AVAILABLE RESOURCES\n\n<design_image_path>\n${tmpImagePath}\n</design_image_path>\n\n<slice_library_path>\n${libraryAbsPath}\n</slice_library_path>\n\n<framework>\n${framework.label}\n</framework>\n\n# AVAILABLE TOOLS\n\nYou have access to specialized Prismic MCP tools for this task:\n\n<tool name=\"mcp__prismic__how_to_model_slice\">\n<description>\nProvides detailed guidance on creating Prismic slice models, including field types, naming conventions, and best practices.\n</description>\n<when_to_use>\nCall this tool in Step 2.1 to learn how to structure the slice model data for the design you analysed.\n</when_to_use>\n</tool>\n\n<tool name=\"mcp__prismic__how_to_code_slice\">\n<description>\nProvides guidance on implementing Prismic slice components, including how to use Prismic field components, props structure, and best practices.\n</description>\n<when_to_use>\nCall this tool in Step 2.1 to learn how to properly structure the slice component with Prismic fields.\n</when_to_use>\n</tool>\n\n<tool name=\"mcp__prismic__save_slice_data\">\n<description>\nValidates and saves the slice model data to model.json. This is the ONLY way to create the model file.\n</description>\n<when_to_use>\nCall this tool in Step 2.3 after you have built the complete slice model structure in memory.\n</when_to_use>\n</tool>\n\n# TASK REQUIREMENTS\n\n## Step 1: Gather information from the design image\n1.1. Analyse the design image at <design_image_path>.\n1.2. Identify all elements in the image that should be dynamically editable (e.g., headings, paragraphs, images, links, buttons, etc.).\n1.3. List the slice directories under <slice_library_path>.\n1.4. Come up with a unique name for the new slice based on the content of the image and the slice directories.\n\n## Step 2: Model the Prismic slice\n2.1. Call mcp__prismic__how_to_model_slice to learn how to structure the model for this design.\n- Make sure the name you use for the new slice does not yet exist in the slice library at <slice_library_path>. If it does, use a different name.\n2.2. Build the complete slice JSON model data in memory based on the guidance received and the information extracted from the image.\n2.3. Call mcp__prismic__save_slice_data to save the model (DO NOT manually write model.json) in the slice library at <slice_library_path>.\n\n## Step 3: Code a boilerplate slice component based on the model\n3.1. Call mcp__prismic__how_to_code_slice to learn how to properly structure the slice component with Prismic fields.\n3.2. Update the slice component code at <slice_library_path>/index.${frameworkFileExtension}, replacing the placeholder code with boilerplate code with the following requirements:\n- Must NOT be based on existing slices or components from the codebase.\n- Must render all the Prismic components to display the fields of the slice model created at <slice_model_path>.\n- Must be a valid ${framework.label} component.\n- Must NOT have any styling/CSS. No inlines styles or classNames. Just the skeleton component structure.\n- Must NOT use any other custom component or functions from the user's codebase.\n- Avoid creating unnecessary wrapper elements, like if they only wrap a single component (e.g., <div><PrismicRichText /></div>).\n\n## Step 4: Present the newly created slice path\n4.1. Present the path to the newly created slice in the following format: <new_slice_path>${libraryAbsPath}/MyNewSlice</new_slice_path>.\n- \"MyNewSlice\" must be the name of the directory of the newly created slice.\n\n# EXAMPLE OF CORRECT EXECUTION\n\n<example>\nAssistant: Step 1.1: Analysing design image...\n[reads <design_image_path>]\n\nStep 1.2: Identifying editable content elements...\n[identifies: title field, description field, buttonText field, buttonLink field, backgroundImage field]\n\nStep 1.3: Listing slice directories under <slice_library_path>...\n[lists slice directories: Hero, Hero2, Hero3]\n\nStep 1.4: Coming up with a unique name for the new slice...\n[comes up with a unique name for the new slice: Hero4]\n\nStep 2.1: Getting Prismic modeling guidance...\n[calls mcp__prismic__how_to_model_slice]\n\nStep 2.2: Building slice model based on guidance and the information extracted...\n[creates model with title field, description field, buttonText field, buttonLink field, backgroundImage field]\n\nStep 2.3: Saving slice model...\n[calls mcp__prismic__save_slice_data]\n\nStep 3.1: Learning Prismic slice coding requirements...\n[calls mcp__prismic__how_to_code_slice]\n\nStep 3.2: Coding boilerplate slice component based on the model...\n[updates component with Prismic field components, no styling, no other components]\n\nStep 4.1: Presenting the path to the newly created slice...\n[presents <new_slice_path>${path.join(\n\t\t\t\t\t\tlibraryAbsPath,\n\t\t\t\t\t\t\"MyNewSlice\",\n\t\t\t\t\t)}</new_slice_path>]\n\n# DELIVERABLES\n- Slice model saved to <slice_library_path>/model.json using mcp__prismic__save_slice_data\n- Slice component at <slice_library_path>/index.${frameworkFileExtension} updated with boilerplate code\n- New slice path presented in the format mentioned in Step 3.1\n\nYOU ARE NOT FINISHED UNTIL YOU HAVE THESE DELIVERABLES.\n\n---\n\nFINAL REMINDERS:\n- You MUST use mcp__prismic__save_slice_data to save the model\n- You MUST call mcp__prismic__how_to_code_slice in Step 3.1\n- DO NOT ATTEMPT TO BUILD THE APPLICATION\n- START IMMEDIATELY WITH STEP 1.1 - NO PRELIMINARY ANALYSIS;`,\n\t\t\t\t\toptions: {\n\t\t\t\t\t\tcwd: libraryAbsPath,\n\t\t\t\t\t\tstderr: (data) => console.error(data),\n\t\t\t\t\t\tmodel: \"claude-haiku-4-5\",\n\t\t\t\t\t\tpermissionMode: \"bypassPermissions\",\n\t\t\t\t\t\tallowedTools: [\n\t\t\t\t\t\t\t\"Bash\",\n\t\t\t\t\t\t\t\"Read\",\n\t\t\t\t\t\t\t\"FileSearch\",\n\t\t\t\t\t\t\t\"Grep\",\n\t\t\t\t\t\t\t\"Glob\",\n\t\t\t\t\t\t\t\"Task\",\n\t\t\t\t\t\t\t\"Edit\",\n\t\t\t\t\t\t\t\"Write\",\n\t\t\t\t\t\t\t\"MultiEdit\",\n\t\t\t\t\t\t\t\"mcp__prismic__how_to_model_slice\",\n\t\t\t\t\t\t\t\"mcp__prismic__how_to_code_slice\",\n\t\t\t\t\t\t\t\"mcp__prismic__save_slice_data\",\n\t\t\t\t\t\t],\n\t\t\t\t\t\tdisallowedTools: [\n\t\t\t\t\t\t\t`Edit(**/model.json)`,\n\t\t\t\t\t\t\t`Write(**/model.json)`,\n\t\t\t\t\t\t\t\"Edit(**/mocks.json)\",\n\t\t\t\t\t\t\t\"Write(**/mocks.json)\",\n\t\t\t\t\t\t],\n\t\t\t\t\t\tenv: {\n\t\t\t\t\t\t\t...process.env,\n\t\t\t\t\t\t\tANTHROPIC_BASE_URL: llmProxyUrl,\n\t\t\t\t\t\t\tANTHROPIC_CUSTOM_HEADERS:\n\t\t\t\t\t\t\t\t`x-prismic-token: ${authToken}\\n` +\n\t\t\t\t\t\t\t\t`x-prismic-repository: ${repository}\\n`,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tmcpServers: {\n\t\t\t\t\t\t\tprismic: {\n\t\t\t\t\t\t\t\ttype: \"stdio\",\n\t\t\t\t\t\t\t\tcommand: \"npx\",\n\t\t\t\t\t\t\t\targs: [\"-y\", \"@prismicio/mcp-server@0.0.20-alpha.6\"],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t});\n\n\t\t\t\tlet newSliceAbsPath: string | undefined;\n\n\t\t\t\tfor await (const query of queries) {\n\t\t\t\t\tswitch (query.type) {\n\t\t\t\t\t\tcase \"result\":\n\t\t\t\t\t\t\tif (query.subtype === \"success\") {\n\t\t\t\t\t\t\t\tnewSliceAbsPath = query.result.match(\n\t\t\t\t\t\t\t\t\t/<new_slice_path>(.*)<\\/new_slice_path>/s,\n\t\t\t\t\t\t\t\t)?.[1];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (!newSliceAbsPath) {\n\t\t\t\t\tthrow new Error(\"Could not find path for the newly created slice.\");\n\t\t\t\t}\n\n\t\t\t\tconst model = await readFile(\n\t\t\t\t\tpath.join(newSliceAbsPath, \"model.json\"),\n\t\t\t\t\t\"utf8\",\n\t\t\t\t);\n\n\t\t\t\tif (!model) {\n\t\t\t\t\tthrow new Error(\"Could not find model for the newly created slice.\");\n\t\t\t\t}\n\n\t\t\t\t// move the screenshot image to the new slice directory\n\t\t\t\tawait rename(\n\t\t\t\t\ttmpImagePath,\n\t\t\t\t\tpath.join(newSliceAbsPath, \"screenshot-default.png\"),\n\t\t\t\t);\n\t\t\t\tawait rm(tmpDir, { recursive: true });\n\n\t\t\t\tconst elapsedTimeSeconds = (Date.now() - startTime) / 1000;\n\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\tconsole.log(`inferSlice took ${elapsedTimeSeconds}s`);\n\n\t\t\t\treturn InferSliceResponse.parse({ slice: JSON.parse(model) });\n\t\t\t} catch (error) {\n\t\t\t\tif (tmpDir && existsSync(tmpDir)) {\n\t\t\t\t\tawait rm(tmpDir, { recursive: true });\n\t\t\t\t}\n\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t} else {\n\t\t\tconst headers = {\n\t\t\t\tAuthorization: `Bearer ${authToken}`,\n\t\t\t};\n\n\t\t\tconst searchParams = new URLSearchParams({\n\t\t\t\trepository,\n\t\t\t});\n\n\t\t\tconst url = new URL(\"./slices/infer\", API_ENDPOINTS.CustomTypeService);\n\t\t\turl.search = searchParams.toString();\n\n\t\t\tconst response = await fetch(url.toString(), {\n\t\t\t\tmethod: \"POST\",\n\t\t\t\theaders: headers,\n\t\t\t\tbody: JSON.stringify({ imageUrl }),\n\t\t\t});\n\n\t\t\tif (!response.ok) {\n\t\t\t\tthrow new Error(`Failed to infer slice: ${response.statusText}`);\n\t\t\t}\n\n\t\t\tconst json = await response.json();\n\n\t\t\treturn InferSliceResponse.parse(json);\n\t\t}\n\t}\n}\n\ntype InferSliceResponse = z.infer<typeof InferSliceResponse>;\n\nconst InferSliceResponse = z.object({\n\tslice: z.custom().transform((value, ctx) => {\n\t\tconst result = SharedSlice.decode(value);\n\t\tif (result._tag === \"Right\") {\n\t\t\treturn result.right;\n\t\t}\n\t\tctx.addIssue({\n\t\t\tcode: z.ZodIssueCode.custom,\n\t\t\tmessage: `Invalid shared slice: ${JSON.stringify(value, null, 2)}`,\n\t\t});\n\n\t\treturn z.NEVER;\n\t}),\n\tlangSmithUrl: z.string().url().optional(),\n});\n\nfunction updateCRCustomType(\n\targs: { customType: LinkCustomType } & CustomTypeFieldIdChangedMeta,\n): LinkCustomType {\n\tconst previousPath = getPathIds(args.previousPath);\n\tconst newPath = getPathIds(args.newPath);\n\n\tif (!previousPath.customTypeId || !newPath.customTypeId) {\n\t\tthrow new Error(\n\t\t\t`Could not find a customtype id in previousPath (${args.previousPath.join(\n\t\t\t\t\".\",\n\t\t\t)}) and/or newPath (${args.newPath.join(\n\t\t\t\t\".\",\n\t\t\t)}), which should not be possible.`,\n\t\t);\n\t}\n\n\tif (!previousPath.fieldId || !newPath.fieldId) {\n\t\tthrow new Error(\n\t\t\t`Could not find a field id in previousPath (${args.previousPath.join(\n\t\t\t\t\".\",\n\t\t\t)}) and/or newPath (${args.newPath.join(\n\t\t\t\t\".\",\n\t\t\t)}), which should not be possible.`,\n\t\t);\n\t}\n\n\tconst customType = shallowCloneIfObject(args.customType);\n\n\tif (typeof customType === \"string\") {\n\t\t// Legacy format support, we don't have anything to update here.\n\t\treturn customType;\n\t}\n\n\tconst matchedCustomTypeId = customType.id === previousPath.customTypeId;\n\n\treturn {\n\t\t...customType,\n\t\tfields: customType.fields.map((fieldArg) => {\n\t\t\tconst customTypeField = shallowCloneIfObject(fieldArg);\n\n\t\t\t// Regular field\n\t\t\tif (typeof customTypeField === \"string\") {\n\t\t\t\tif (\n\t\t\t\t\tmatchedCustomTypeId &&\n\t\t\t\t\tcustomTypeField === previousPath.fieldId &&\n\t\t\t\t\tcustomTypeField !== newPath.fieldId\n\t\t\t\t) {\n\t\t\t\t\t// The id of the field has changed.\n\t\t\t\t\treturn newPath.fieldId;\n\t\t\t\t}\n\n\t\t\t\treturn customTypeField;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tmatchedCustomTypeId &&\n\t\t\t\tcustomTypeField.id === previousPath.fieldId &&\n\t\t\t\tcustomTypeField.id !== newPath.fieldId\n\t\t\t) {\n\t\t\t\t// The id of the field has changed. We don't exit return because there\n\t\t\t\t// might be other fields further down in nested custom types or groups\n\t\t\t\t// that need to be updated.\n\t\t\t\tcustomTypeField.id = newPath.fieldId;\n\t\t\t}\n\n\t\t\t// Group field\n\t\t\tif (\"fields\" in customTypeField) {\n\t\t\t\tif (\n\t\t\t\t\t!previousPath.groupId &&\n\t\t\t\t\t!newPath.groupId &&\n\t\t\t\t\tcustomTypeField.id === previousPath.fieldId &&\n\t\t\t\t\tcustomTypeField.id !== newPath.fieldId\n\t\t\t\t) {\n\t\t\t\t\t// Only the id of the group has changed. Group id is not defined, so\n\t\t\t\t\t// we can return early.\n\t\t\t\t\treturn newPath.fieldId;\n\t\t\t\t}\n\n\t\t\t\tconst matchedGroupId = customTypeField.id === previousPath.groupId;\n\n\t\t\t\tif (\n\t\t\t\t\tpreviousPath.groupId &&\n\t\t\t\t\tnewPath.groupId &&\n\t\t\t\t\tmatchedGroupId &&\n\t\t\t\t\tcustomTypeField.id !== newPath.groupId\n\t\t\t\t) {\n\t\t\t\t\t// The id of the group field has changed, so we update it. We don't\n\t\t\t\t\t// return because there are group fields that may need to be updated.\n\t\t\t\t\tcustomTypeField.id = newPath.groupId;\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\t...customTypeField,\n\t\t\t\t\tfields: customTypeField.fields.map((groupFieldArg) => {\n\t\t\t\t\t\tconst groupField = shallowCloneIfObject(groupFieldArg);\n\n\t\t\t\t\t\t// Regular field inside a group field\n\t\t\t\t\t\tif (typeof groupField === \"string\") {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tmatchedGroupId &&\n\t\t\t\t\t\t\t\tgroupField === previousPath.fieldId &&\n\t\t\t\t\t\t\t\tgroupField !== newPath.fieldId\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t// The id of the field inside the group has changed.\n\t\t\t\t\t\t\t\treturn newPath.fieldId;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\treturn groupField;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Content relationship field inside a group field\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...groupField,\n\t\t\t\t\t\t\tfields: updateContentRelationshipFields({\n\t\t\t\t\t\t\t\tcustomtypes: groupField.customtypes,\n\t\t\t\t\t\t\t\tpreviousPath,\n\t\t\t\t\t\t\t\tnewPath,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t};\n\t\t\t\t\t}),\n\t\t\t\t};\n\t\t\t}\n\n\t\t\t// Content relationship field\n\t\t\treturn {\n\t\t\t\t...customTypeField,\n\t\t\t\tcustomtypes: updateContentRelationshipFields({\n\t\t\t\t\tcustomtypes: customTypeField.customtypes,\n\t\t\t\t\tpreviousPath,\n\t\t\t\t\tnewPath,\n\t\t\t\t}),\n\t\t\t};\n\t\t}),\n\t};\n}\n\nfunction updateContentRelationshipFields(args: {\n\tcustomtypes: readonly (\n\t\t| string\n\t\t| {\n\t\t\t\tid: string;\n\t\t\t\tfields: readonly (string | { id: string; fields: readonly string[] })[];\n\t\t }\n\t)[];\n\tpreviousPath: CrUpdatePathIds;\n\tnewPath: CrUpdatePathIds;\n}) {\n\tconst { customtypes, previousPath, newPath } = args;\n\n\treturn customtypes.map((nestedCtArg) => {\n\t\tconst nestedCt = shallowCloneIfObject(nestedCtArg);\n\n\t\tif (\n\t\t\ttypeof nestedCt === \"string\" ||\n\t\t\t// Since we are entering a new custom type, if the previous id\n\t\t\t// doesn't match, we can return early, because it's not the\n\t\t\t// custom type we are looking for.\n\t\t\tnestedCt.id !== previousPath.customTypeId\n\t\t) {\n\t\t\treturn nestedCt;\n\t\t}\n\n\t\treturn {\n\t\t\t...nestedCt,\n\t\t\tfields: nestedCt.fields.map((nestedCtFieldArg) => {\n\t\t\t\tconst nestedCtField = shallowCloneIfObject(nestedCtFieldArg);\n\n\t\t\t\t// Regular field\n\t\t\t\tif (typeof nestedCtField === \"string\") {\n\t\t\t\t\tif (\n\t\t\t\t\t\tnestedCtField === previousPath.fieldId &&\n\t\t\t\t\t\tnestedCtField !== newPath.fieldId\n\t\t\t\t\t) {\n\t\t\t\t\t\t// The id of the field has changed.\n\t\t\t\t\t\treturn newPath.fieldId;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn nestedCtField;\n\t\t\t\t}\n\n\t\t\t\t// Group field\n\n\t\t\t\tif (\n\t\t\t\t\tnestedCtField.id === previousPath.fieldId &&\n\t\t\t\t\tnestedCtField.id !== newPath.fieldId\n\t\t\t\t) {\n\t\t\t\t\t// The id of the field has changed.\n\t\t\t\t\tnestedCtField.id = newPath.fieldId;\n\t\t\t\t}\n\n\t\t\t\t// Further down the path, the field can only be a group field. So if we have\n\t\t\t\t// no group id defined, no need to continue.\n\t\t\t\tif (\n\t\t\t\t\t!previousPath.groupId ||\n\t\t\t\t\t!newPath.groupId ||\n\t\t\t\t\tnestedCtField.id !== previousPath.groupId\n\t\t\t\t) {\n\t\t\t\t\treturn nestedCtField;\n\t\t\t\t}\n\n\t\t\t\tif (nestedCtField.id !== newPath.groupId) {\n\t\t\t\t\t// The id of the group has changed.\n\t\t\t\t\tnestedCtField.id = newPath.groupId;\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\t...nestedCtField,\n\t\t\t\t\tfields: nestedCtField.fields.map((nestedCtGroupFieldId) => {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tnestedCtGroupFieldId === previousPath.fieldId &&\n\t\t\t\t\t\t\tnestedCtGroupFieldId !== newPath.fieldId\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t// The id of the field inside the group has changed.\n\t\t\t\t\t\t\treturn newPath.fieldId;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn nestedCtGroupFieldId;\n\t\t\t\t\t}),\n\t\t\t\t};\n\t\t\t}),\n\t\t};\n\t});\n}\n\n/**\n * Update the Content Relationship API IDs of a single field. The change is\n * determined by the `previousPath` and `newPath` properties.\n */\nfunction updateFieldContentRelationships<\n\tT extends UID | NestableWidget | Group | NestedGroup,\n>(args: { field: T } & CustomTypeFieldIdChangedMeta): T {\n\tconst { field, ...updateMeta } = args;\n\tif (\n\t\tfield.type !== \"Link\" ||\n\t\tfield.config?.select !== \"document\" ||\n\t\t!field.config?.customtypes\n\t) {\n\t\t// not a content relationship field\n\t\treturn field;\n\t}\n\n\tconst newCustomTypes = field.config.customtypes.map((customType) => {\n\t\treturn updateCRCustomType({ ...updateMeta, customType });\n\t});\n\n\treturn {\n\t\t...field,\n\t\tconfig: { ...field.config, customtypes: newCustomTypes },\n\t};\n}\n\nexport function updateCustomTypeContentRelationships(\n\targs: {\n\t\tmodels: { model: CustomType }[];\n\t\tonUpdate: (model: { previousModel: CustomType; model: CustomType }) => void;\n\t} & CustomTypeFieldIdChangedMeta,\n): void {\n\tconst { models, previousPath, newPath, onUpdate } = args;\n\n\tfor (const { model: customType } of models) {\n\t\tconst updatedCustomType = traverseCustomType({\n\t\t\tcustomType,\n\t\t\tonField: ({ field }) => {\n\t\t\t\treturn updateFieldContentRelationships({\n\t\t\t\t\tfield,\n\t\t\t\t\tpreviousPath,\n\t\t\t\t\tnewPath,\n\t\t\t\t});\n\t\t\t},\n\t\t});\n\n\t\tif (!isEqualModel(customType, updatedCustomType)) {\n\t\t\tonUpdate({ model: updatedCustomType, previousModel: customType });\n\t\t}\n\t}\n}\n\nexport function updateSharedSliceContentRelationships(\n\targs: {\n\t\tmodels: { model: SharedSlice }[];\n\t\tonUpdate: (model: {\n\t\t\tpreviousModel: SharedSlice;\n\t\t\tmodel: SharedSlice;\n\t\t}) => void;\n\t} & CustomTypeFieldIdChangedMeta,\n): void {\n\tconst { models, previousPath, newPath, onUpdate } = args;\n\n\tfor (const { model: slice } of models) {\n\t\tconst updateSlice = traverseSharedSlice({\n\t\t\tpath: [],\n\t\t\tslice,\n\t\t\tonField: ({ field }) => {\n\t\t\t\treturn updateFieldContentRelationships({\n\t\t\t\t\tfield,\n\t\t\t\t\tpreviousPath,\n\t\t\t\t\tnewPath,\n\t\t\t\t});\n\t\t\t},\n\t\t});\n\n\t\tif (!isEqualModel(slice, updateSlice)) {\n\t\t\tonUpdate({ model: updateSlice, previousModel: slice });\n\t\t}\n\t}\n}\n\ninterface CrUpdatePathIds {\n\tcustomTypeId: string;\n\tgroupId: string | undefined;\n\tfieldId: string;\n}\n\nfunction getPathIds(path: PathWithCustomType): CrUpdatePathIds {\n\tif (path.length < 2) {\n\t\tthrow new Error(\n\t\t\t`Unexpected path length ${\n\t\t\t\tpath.length\n\t\t\t}. Expected at least 2 segments (got: ${path.join(\".\")}).`,\n\t\t);\n\t}\n\n\tconst [customTypeId, groupOrFieldId, fieldId] = path;\n\n\treturn {\n\t\tcustomTypeId,\n\t\t/**\n\t\t * Id of a changed group. If it's defined, it means that a group or a field\n\t\t * inside a group had its API ID renamed. It's defined when the path has a\n\t\t * third element (e.g. `[\"customtypeA\", \"groupA\", \"fieldA\"]`).\n\t\t */\n\t\tgroupId: fieldId ? groupOrFieldId : undefined,\n\t\tfieldId: fieldId || groupOrFieldId,\n\t};\n}\n\nfunction isEqualModel<T extends CustomType | SharedSlice>(\n\tmodelA: T,\n\tmodelB: T,\n): boolean {\n\treturn JSON.stringify(modelA) === JSON.stringify(modelB);\n}\n\nfunction shallowCloneIfObject<T>(value: T): T {\n\tif (typeof value === \"object\") {\n\t\treturn { ...value };\n\t}\n\n\treturn value;\n}\n"],"names":["BaseManager","assertPluginsInitialized","errors","decodeHookResult","t","CustomType","_a","prismicCustomTypesClient","API_ENDPOINTS","fetch","SLICE_MACHINE_USER_AGENT","UnauthorizedError","z","mkdtemp","tmpdir","randomUUID","writeFile","queryClaude","readFile","rename","rm","existsSync","SharedSlice","customtypes","traverseCustomType","traverseSharedSlice","path"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuIM,MAAO,2BAA2BA,YAAAA,YAAW;AAAA,EAClD,MAAM,wBAAqB;;AAC1BC,6BAAAA,yBAAyB,KAAK,wBAAwB;AAEtD,UAAM,aAAa,MAAM,KAAK,yBAAyB,SACtD,4BACA,MAAS;AAEV,UAAM,EAAE,MAAM,QAAAC,QAAA,IAAWC,iBAAAA,iBACxBC,aAAE,KAAK;AAAA,MACN,KAAKA,aAAE,MAAMA,aAAE,MAAM;AAAA,IAAA,CACrB,GACD,UAAU;AAGX,WAAO;AAAA,MACN,OAAK,UAAK,CAAC,MAA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IA,MAAK,SAAS,GAAG;AACpB,UAAM,IAAI,MACT,0BACCA,MAAK,MACN,wCAAwCA,MAAK,KAAK,GAAG,CAAC,IAAI;AAAA,EAE5D;AAEA,QAAM,CAAC,cAAc,gBAAgB,OAAO,IAAIA;AAEhD,SAAO;AAAA,IACN;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMA,SAAS,UAAU,iBAAiB;AAAA,IACpC,SAAS,WAAW;AAAA,EAAA;AAEtB;AAEA,SAAS,aACR,QACA,QAAS;AAET,SAAO,KAAK,UAAU,MAAM,MAAM,KAAK,UAAU,MAAM;AACxD;AAEA,SAAS,qBAAwB,OAAQ;AACxC,MAAI,OAAO,UAAU,UAAU;AAC9B,WAAO,EAAE,GAAG,MAAA;AAAA,EACb;AAEA,SAAO;AACR;;;;"}
@@ -280,6 +280,11 @@ class CustomTypesManager extends BaseManager {
280
280
  async inferSlice(args) {
281
281
  var _a;
282
282
  const { source, imageUrl } = args;
283
+ const exp = await this.telemetry.getExperimentVariant("llm-proxy-access");
284
+ if ((exp == null ? void 0 : exp.value) !== "on") {
285
+ throw new Error("LLM proxy access is not enabled.");
286
+ }
287
+ const { llmProxyUrl } = z.object({ llmProxyUrl: z.string() }).parse(exp.payload);
283
288
  const authToken = await this.user.getAuthenticationToken();
284
289
  const repository = await this.project.getResolvedRepositoryName();
285
290
  if (source === "figma") {
@@ -482,7 +487,7 @@ FINAL REMINDERS:
482
487
  ],
483
488
  env: {
484
489
  ...process.env,
485
- ANTHROPIC_BASE_URL: API_ENDPOINTS.LlmProxyTypeService,
490
+ ANTHROPIC_BASE_URL: llmProxyUrl,
486
491
  ANTHROPIC_CUSTOM_HEADERS: `x-prismic-token: ${authToken}
487
492
  x-prismic-repository: ${repository}
488
493
  `
@@ -1 +1 @@
1
- {"version":3,"file":"CustomTypesManager.js","sources":["../../../../src/managers/customTypes/CustomTypesManager.ts"],"sourcesContent":["import * as t from \"io-ts\";\nimport * as prismicCustomTypesClient from \"@prismicio/custom-types-client\";\nimport {\n\tCustomType,\n\tGroup,\n\tLinkConfig,\n\tNestableWidget,\n\tNestedGroup,\n\tSharedSlice,\n\tUID,\n\ttraverseCustomType,\n\ttraverseSharedSlice,\n} from \"@prismicio/types-internal/lib/customtypes\";\nimport {\n\tCallHookReturnType,\n\tCustomTypeCreateHook,\n\tCustomTypeCreateHookData,\n\tCustomTypeReadHookData,\n\tCustomTypeRenameHook,\n\tCustomTypeRenameHookData,\n\tCustomTypeUpdateHook,\n\tCustomTypeUpdateHookData,\n\tHookError,\n} from \"@slicemachine/plugin-kit\";\nimport { z } from \"zod\";\nimport { query as queryClaude } from \"@anthropic-ai/claude-agent-sdk\";\n\nimport { DecodeError } from \"../../lib/DecodeError\";\nimport { assertPluginsInitialized } from \"../../lib/assertPluginsInitialized\";\nimport { decodeHookResult } from \"../../lib/decodeHookResult\";\nimport fetch from \"../../lib/fetch\";\n\nimport { OnlyHookErrors } from \"../../types\";\nimport { API_ENDPOINTS } from \"../../constants/API_ENDPOINTS\";\nimport { SLICE_MACHINE_USER_AGENT } from \"../../constants/SLICE_MACHINE_USER_AGENT\";\nimport { UnauthorizedError } from \"../../errors\";\nimport { mkdtemp, readFile, rename, rm, writeFile } from \"fs/promises\";\nimport { tmpdir } from \"os\";\nimport path from \"path\";\nimport { randomUUID } from \"crypto\";\nimport { existsSync } from \"fs\";\n\nimport { BaseManager } from \"../BaseManager\";\nimport { CustomTypeFormat } from \"./types\";\n\ntype SliceMachineManagerReadCustomTypeLibraryReturnType = {\n\tids: string[];\n\terrors: (DecodeError | HookError)[];\n};\n\ntype CustomTypesManagerReadAllCustomTypesArgs = {\n\tformat: CustomTypeFormat;\n};\n\ntype SliceMachineManagerReadAllCustomTypeReturnType = {\n\tmodels: { model: CustomType }[];\n\terrors: (DecodeError | HookError)[];\n};\n\ntype SliceMachineManagerReadCustomTypeReturnType = {\n\tmodel: CustomType | undefined;\n\terrors: (DecodeError | HookError)[];\n};\n\ntype SliceMachineManagerPushCustomTypeArgs = {\n\tid: string;\n\tuserAgent?: string;\n};\n\ntype SliceMachineManagerReadCustomTypeMocksConfigArgs = {\n\tcustomTypeID: string;\n};\n\ntype SliceMachineManagerReadCustomTypeMocksConfigArgsReturnType = {\n\t// TODO\n\tmocksConfig?: Record<string, unknown>;\n\terrors: HookError[];\n};\n\ntype SliceMachineManagerUpdateCustomTypeMocksConfigArgs = {\n\tcustomTypeID: string;\n\t// TODO\n\tmocksConfig: Record<string, unknown>;\n};\n\n/** `[field]` or `[group, field]` – path **inside** the Custom Type */\ntype PathWithoutCustomType = [string] | [string, string];\n\ntype SliceMachineManagerUpdateCustomTypeFieldIdChanged = {\n\t/**\n\t * Previous path of the changed field, excluding the custom type id. Can be\n\t * used to identify the field that had an API ID rename (e.g. [\"fieldA\"] or\n\t * [\"groupA\", \"fieldA\"])\n\t */\n\tpreviousPath: PathWithoutCustomType;\n\t/**\n\t * New path of the changed field, excluding the custom type id. Can be used to\n\t * identify the field that had an API ID rename (e.g. [\"fieldB\"] or [\"groupA\",\n\t * \"fieldB\"])\n\t */\n\tnewPath: PathWithoutCustomType;\n};\n\ntype SliceMachineManagerUpdateCustomTypeArgs = CustomTypeUpdateHookData & {\n\tupdateMeta?: {\n\t\tfieldIdChanged?: SliceMachineManagerUpdateCustomTypeFieldIdChanged;\n\t};\n};\n\ntype SliceMachineManagerUpdateCustomTypeMocksConfigArgsReturnType = {\n\terrors: HookError[];\n};\n\ntype CustomTypesMachineManagerDeleteCustomTypeArgs = {\n\tid: string;\n};\n\ntype CustomTypesMachineManagerDeleteCustomTypeReturnType = {\n\terrors: (DecodeError | HookError)[];\n};\n\ntype CustomTypesMachineManagerUpdateCustomTypeReturnType = {\n\terrors: (DecodeError | HookError)[];\n};\n\n/** `[ct, field]` or `[ct, group, field]` – path **with** Custom Type ID */\ntype PathWithCustomType = [string, string] | [string, string, string];\n\ntype CustomTypeFieldIdChangedMeta = {\n\tpreviousPath: PathWithCustomType;\n\tnewPath: PathWithCustomType;\n};\n\ntype LinkCustomType = NonNullable<LinkConfig[\"customtypes\"]>[number];\n\nexport class CustomTypesManager extends BaseManager {\n\tasync readCustomTypeLibrary(): Promise<SliceMachineManagerReadCustomTypeLibraryReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type-library:read\",\n\t\t\tundefined,\n\t\t);\n\t\tconst { data, errors } = decodeHookResult(\n\t\t\tt.type({\n\t\t\t\tids: t.array(t.string),\n\t\t\t}),\n\t\t\thookResult,\n\t\t);\n\n\t\treturn {\n\t\t\tids: data[0]?.ids || [],\n\t\t\terrors,\n\t\t};\n\t}\n\n\tasync readAllCustomTypes(\n\t\targs?: CustomTypesManagerReadAllCustomTypesArgs,\n\t): Promise<SliceMachineManagerReadAllCustomTypeReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst res: SliceMachineManagerReadAllCustomTypeReturnType = {\n\t\t\tmodels: [],\n\t\t\terrors: [],\n\t\t};\n\n\t\tconst { ids, errors } = await this.readCustomTypeLibrary();\n\t\tres.errors = [...res.errors, ...errors];\n\n\t\tif (ids) {\n\t\t\tfor (const id of ids) {\n\t\t\t\tconst { model, errors } = await this.readCustomType({ id });\n\t\t\t\tres.errors = [...res.errors, ...errors];\n\n\t\t\t\tif (model && (!args || args.format === model.format)) {\n\t\t\t\t\tres.models.push({ model });\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn res;\n\t}\n\n\tasync createCustomType(\n\t\targs: CustomTypeCreateHookData,\n\t): Promise<OnlyHookErrors<CallHookReturnType<CustomTypeCreateHook>>> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:create\",\n\t\t\targs,\n\t\t);\n\n\t\treturn {\n\t\t\terrors: hookResult.errors,\n\t\t};\n\t}\n\n\tasync readCustomType(\n\t\targs: CustomTypeReadHookData,\n\t): Promise<SliceMachineManagerReadCustomTypeReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:read\",\n\t\t\targs,\n\t\t);\n\t\tconst { data, errors } = decodeHookResult(\n\t\t\tt.type({\n\t\t\t\tmodel: CustomType,\n\t\t\t}),\n\t\t\thookResult,\n\t\t);\n\n\t\treturn {\n\t\t\tmodel: data[0]?.model,\n\t\t\terrors,\n\t\t};\n\t}\n\n\t/**\n\t * Update the Content Relationship API IDs for all existing custom types and\n\t * slices. The change is determined by properties inside the `updateMeta`\n\t * property.\n\t */\n\tprivate async updateContentRelationships(\n\t\targs: {\n\t\t\tmodel: CustomType;\n\t\t} & SliceMachineManagerUpdateCustomTypeFieldIdChanged,\n\t): Promise<\n\t\tOnlyHookErrors<CallHookReturnType<CustomTypeUpdateHook>> & {\n\t\t\trollback?: () => Promise<void>;\n\t\t}\n\t> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst {\n\t\t\tmodel,\n\t\t\tpreviousPath: previousFieldPath,\n\t\t\tnewPath: newFieldPath,\n\t\t} = args;\n\n\t\tif (previousFieldPath.join(\".\") !== newFieldPath.join(\".\")) {\n\t\t\tconst { id: ctId } = model;\n\t\t\tconst previousPath: PathWithCustomType = [ctId, ...previousFieldPath];\n\t\t\tconst newPath: PathWithCustomType = [ctId, ...newFieldPath];\n\n\t\t\tconst crUpdates: {\n\t\t\t\tupdatePromise: Promise<{ errors: HookError[] }>;\n\t\t\t\trollback: () => void;\n\t\t\t}[] = [];\n\n\t\t\t// Find existing content relationships that link to the renamed field id in\n\t\t\t// any custom type and update them to use the new one.\n\t\t\tconst customTypes = await this.readAllCustomTypes();\n\n\t\t\tupdateCustomTypeContentRelationships({\n\t\t\t\tmodels: customTypes.models,\n\t\t\t\tonUpdate: ({ previousModel, model: updatedModel }) => {\n\t\t\t\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\t\t\t\tcrUpdates.push({\n\t\t\t\t\t\tupdatePromise: this.sliceMachinePluginRunner?.callHook(\n\t\t\t\t\t\t\t\"custom-type:update\",\n\t\t\t\t\t\t\t{ model: updatedModel },\n\t\t\t\t\t\t),\n\t\t\t\t\t\trollback: () => {\n\t\t\t\t\t\t\tthis.sliceMachinePluginRunner?.callHook(\"custom-type:update\", {\n\t\t\t\t\t\t\t\tmodel: previousModel,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t},\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\tpreviousPath,\n\t\t\t\tnewPath,\n\t\t\t});\n\n\t\t\t// Find existing slice with content relationships that link to the renamed\n\t\t\t// field id in all libraries and update them to use the new one.\n\t\t\tconst { libraries } = await this.slices.readAllSliceLibraries();\n\n\t\t\tfor (const library of libraries) {\n\t\t\t\tconst slices = await this.slices.readAllSlicesForLibrary({\n\t\t\t\t\tlibraryID: library.libraryID,\n\t\t\t\t});\n\n\t\t\t\tupdateSharedSliceContentRelationships({\n\t\t\t\t\tmodels: slices.models,\n\t\t\t\t\tonUpdate: ({ previousModel, model: updatedModel }) => {\n\t\t\t\t\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\t\t\t\t\tcrUpdates.push({\n\t\t\t\t\t\t\tupdatePromise: this.sliceMachinePluginRunner?.callHook(\n\t\t\t\t\t\t\t\t\"slice:update\",\n\t\t\t\t\t\t\t\t{ libraryID: library.libraryID, model: updatedModel },\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\trollback: () => {\n\t\t\t\t\t\t\t\tthis.sliceMachinePluginRunner?.callHook(\"slice:update\", {\n\t\t\t\t\t\t\t\t\tlibraryID: library.libraryID,\n\t\t\t\t\t\t\t\t\tmodel: previousModel,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t});\n\t\t\t\t\t},\n\t\t\t\t\tpreviousPath,\n\t\t\t\t\tnewPath,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// Process all the Content Relationship updates at once.\n\t\t\tconst crUpdatesResult = await Promise.all(\n\t\t\t\tcrUpdates.map((update) => update.updatePromise),\n\t\t\t);\n\n\t\t\tif (crUpdatesResult.some((result) => result.errors.length > 0)) {\n\t\t\t\treturn {\n\t\t\t\t\terrors: crUpdatesResult.flatMap((result) => result.errors),\n\t\t\t\t\trollback: async () => {\n\t\t\t\t\t\tawait Promise.all(crUpdates.map((update) => update.rollback()));\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\treturn { errors: [] };\n\t}\n\n\tasync updateCustomType(\n\t\targs: SliceMachineManagerUpdateCustomTypeArgs,\n\t): Promise<CustomTypesMachineManagerUpdateCustomTypeReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\t\tconst { model } = args;\n\t\tconst { fieldIdChanged } = args.updateMeta ?? {};\n\n\t\tlet previousCustomType: CustomType | undefined;\n\n\t\tif (fieldIdChanged) {\n\t\t\tconst customTypeRead = await this.readCustomType({ id: model.id });\n\n\t\t\tif (customTypeRead.errors.length > 0) {\n\t\t\t\treturn { errors: customTypeRead.errors };\n\t\t\t}\n\t\t\tif (!customTypeRead.model) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`readCustomType succeeded reading custom type ${model.id} but model is undefined.`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tpreviousCustomType = customTypeRead.model;\n\t\t}\n\n\t\tconst customTypeUpdateResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:update\",\n\t\t\t{ model },\n\t\t);\n\n\t\tif (customTypeUpdateResult.errors.length > 0) {\n\t\t\treturn { errors: customTypeUpdateResult.errors };\n\t\t}\n\n\t\tif (previousCustomType && fieldIdChanged) {\n\t\t\tconst crUpdateResult = await this.updateContentRelationships({\n\t\t\t\t...fieldIdChanged,\n\t\t\t\tmodel: previousCustomType,\n\t\t\t});\n\n\t\t\tif (crUpdateResult.errors.length > 0) {\n\t\t\t\t// put the previous custom type back\n\t\t\t\tawait this.sliceMachinePluginRunner?.callHook(\"custom-type:update\", {\n\t\t\t\t\tmodel: previousCustomType,\n\t\t\t\t});\n\t\t\t\t// revert the content relationships updates\n\t\t\t\tawait crUpdateResult.rollback?.();\n\n\t\t\t\treturn { errors: crUpdateResult.errors };\n\t\t\t}\n\t\t}\n\n\t\treturn { errors: [] };\n\t}\n\n\tasync renameCustomType(\n\t\targs: CustomTypeRenameHookData,\n\t): Promise<OnlyHookErrors<CallHookReturnType<CustomTypeRenameHook>>> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:rename\",\n\t\t\targs,\n\t\t);\n\n\t\treturn {\n\t\t\terrors: hookResult.errors,\n\t\t};\n\t}\n\n\tasync deleteCustomType(\n\t\targs: CustomTypesMachineManagerDeleteCustomTypeArgs,\n\t): Promise<CustomTypesMachineManagerDeleteCustomTypeReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst { model, errors: readCustomTypeErrors } = await this.readCustomType({\n\t\t\tid: args.id,\n\t\t});\n\n\t\tif (model) {\n\t\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\t\"custom-type:delete\",\n\t\t\t\t{ model },\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\terrors: hookResult.errors,\n\t\t\t};\n\t\t} else {\n\t\t\treturn {\n\t\t\t\terrors: readCustomTypeErrors,\n\t\t\t};\n\t\t}\n\t}\n\n\tasync pushCustomType(\n\t\targs: SliceMachineManagerPushCustomTypeArgs,\n\t): Promise<void> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst authenticationToken = await this.user.getAuthenticationToken();\n\t\tconst repositoryName = await this.project.getResolvedRepositoryName();\n\n\t\t// TODO: Handle errors\n\t\tconst { model } = await this.readCustomType({ id: args.id });\n\n\t\tif (model) {\n\t\t\t// TODO: Create a single shared client.\n\t\t\tconst client = prismicCustomTypesClient.createClient({\n\t\t\t\tendpoint: API_ENDPOINTS.PrismicModels,\n\t\t\t\trepositoryName,\n\t\t\t\ttoken: authenticationToken,\n\t\t\t\tfetch,\n\t\t\t\tfetchOptions: {\n\t\t\t\t\theaders: {\n\t\t\t\t\t\t\"User-Agent\": args.userAgent || SLICE_MACHINE_USER_AGENT,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t});\n\n\t\t\ttry {\n\t\t\t\t// Check if Custom Type already exists on the repository.\n\t\t\t\tawait client.getCustomTypeByID(args.id);\n\n\t\t\t\t// If it exists on the repository, update it.\n\t\t\t\tawait client.updateCustomType(model);\n\t\t\t} catch (error) {\n\t\t\t\tif (error instanceof prismicCustomTypesClient.NotFoundError) {\n\t\t\t\t\t// If it doesn't exist on the repository, insert it.\n\t\t\t\t\tawait client.insertCustomType(model);\n\t\t\t\t} else if (error instanceof prismicCustomTypesClient.ForbiddenError) {\n\t\t\t\t\tthrow new UnauthorizedError(\n\t\t\t\t\t\t\"You do not have access to push types to this Prismic repository.\",\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcause: error,\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// TODO: Remove\n\tasync readCustomTypeMocksConfig(\n\t\targs: SliceMachineManagerReadCustomTypeMocksConfigArgs,\n\t): Promise<SliceMachineManagerReadCustomTypeMocksConfigArgsReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:asset:read\",\n\t\t\t{\n\t\t\t\tcustomTypeID: args.customTypeID,\n\t\t\t\tassetID: \"mocks.config.json\",\n\t\t\t},\n\t\t);\n\t\tconst data = hookResult.data[0]?.data;\n\n\t\t// TODO: Validate the returned data.\n\n\t\tif (data) {\n\t\t\treturn {\n\t\t\t\tmocksConfig: JSON.parse(data.toString()),\n\t\t\t\terrors: hookResult.errors,\n\t\t\t};\n\t\t} else {\n\t\t\treturn {\n\t\t\t\tmocksConfig: undefined,\n\t\t\t\terrors: hookResult.errors,\n\t\t\t};\n\t\t}\n\t}\n\n\t// TODO: Remove\n\tasync updateCustomTypeMocksConfig(\n\t\targs: SliceMachineManagerUpdateCustomTypeMocksConfigArgs,\n\t): Promise<SliceMachineManagerUpdateCustomTypeMocksConfigArgsReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:asset:update\",\n\t\t\t{\n\t\t\t\tcustomTypeID: args.customTypeID,\n\t\t\t\tasset: {\n\t\t\t\t\tid: \"mocks.config.json\",\n\t\t\t\t\tdata: Buffer.from(JSON.stringify(args.mocksConfig, null, \"\\t\")),\n\t\t\t\t},\n\t\t\t},\n\t\t);\n\n\t\treturn {\n\t\t\terrors: hookResult.errors,\n\t\t};\n\t}\n\n\tasync fetchRemoteCustomTypes(): Promise<CustomType[]> {\n\t\tconst authenticationToken = await this.user.getAuthenticationToken();\n\t\tconst repositoryName = await this.project.getResolvedRepositoryName();\n\n\t\tconst client = prismicCustomTypesClient.createClient({\n\t\t\tendpoint: API_ENDPOINTS.PrismicModels,\n\t\t\trepositoryName,\n\t\t\ttoken: authenticationToken,\n\t\t\tfetch,\n\t\t\tfetchOptions: {\n\t\t\t\theaders: {\n\t\t\t\t\t\"User-Agent\": SLICE_MACHINE_USER_AGENT,\n\t\t\t\t},\n\t\t\t},\n\t\t});\n\n\t\treturn await client.getAllCustomTypes();\n\t}\n\n\tasync inferSlice(\n\t\targs: { imageUrl: string } & (\n\t\t\t| { source: \"upload\" }\n\t\t\t| { source: \"figma\"; libraryID: string }\n\t\t),\n\t): Promise<InferSliceResponse> {\n\t\tconst { source, imageUrl } = args;\n\t\tconst authToken = await this.user.getAuthenticationToken();\n\t\tconst repository = await this.project.getResolvedRepositoryName();\n\n\t\tif (source === \"figma\") {\n\t\t\tconst { libraryID } = args;\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.log(`inferSlice started`);\n\t\t\tconst startTime = Date.now();\n\n\t\t\tlet tmpDir: string | undefined;\n\t\t\ttry {\n\t\t\t\tconst config = await this.project.getSliceMachineConfig();\n\n\t\t\t\tlet framework:\n\t\t\t\t\t| { type: \"nextjs\" | \"nuxt\" | \"sveltekit\"; label: string }\n\t\t\t\t\t| undefined;\n\t\t\t\tif (config.adapter === \"@slicemachine/adapter-next\") {\n\t\t\t\t\tframework = { type: \"nextjs\", label: \"Next.js (React)\" };\n\t\t\t\t} else if (\n\t\t\t\t\tconfig.adapter === \"@slicemachine/adapter-nuxt\" ||\n\t\t\t\t\tconfig.adapter === \"@slicemachine/adapter-nuxt2\"\n\t\t\t\t) {\n\t\t\t\t\tframework = { type: \"nuxt\", label: \"Nuxt (Vue)\" };\n\t\t\t\t} else if (config.adapter === \"@slicemachine/adapter-sveltekit\") {\n\t\t\t\t\tframework = { type: \"sveltekit\", label: \"SvelteKit (Svelte)\" };\n\t\t\t\t}\n\n\t\t\t\tif (!framework) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\"Could not determine framework from Slice Machine config.\",\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tlet frameworkFileExtension: string | undefined;\n\t\t\t\tif (framework.type === \"nextjs\") {\n\t\t\t\t\tframeworkFileExtension = \"tsx\";\n\t\t\t\t} else if (framework.type === \"nuxt\") {\n\t\t\t\t\tframeworkFileExtension = \"vue\";\n\t\t\t\t} else if (framework.type === \"sveltekit\") {\n\t\t\t\t\tframeworkFileExtension = \"svelte\";\n\t\t\t\t}\n\n\t\t\t\tif (!frameworkFileExtension) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\"Could not determine framework from Slice Machine config.\",\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tconst projectRoot = await this.project.getRoot();\n\t\t\t\tconst libraryAbsPath = path.join(projectRoot, libraryID);\n\n\t\t\t\ttmpDir = await mkdtemp(\n\t\t\t\t\tpath.join(tmpdir(), \"slice-machine-infer-slice-tmp-\"),\n\t\t\t\t);\n\t\t\t\tconst tmpImagePath = path.join(tmpDir, `${randomUUID()}.png`);\n\t\t\t\tconst response = await fetch(imageUrl);\n\t\t\t\tif (!response.ok) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Failed to download image: ${response.status} ${response.statusText}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tawait writeFile(\n\t\t\t\t\ttmpImagePath,\n\t\t\t\t\tBuffer.from(await response.arrayBuffer()),\n\t\t\t\t);\n\n\t\t\t\tconst queries = queryClaude({\n\t\t\t\t\tprompt: `CRITICAL INSTRUCTIONS - READ FIRST:\n- You MUST start immediately with Step 1.1. DO NOT read, analyze, or explore any project files first.\n- Work step-by-step through the numbered tasks below.\n- DO NOT present any summary, explanation, or completion message after finishing.\n- DO NOT create TODO lists while performing tasks.\n- Keep responses minimal - only show necessary tool calls and brief progress notes.\n\n# CONTEXT \n\nThe user wants to build a new Prismic Slice based on a design image they provided.\nYour goal is to analyze the design image and generate the JSON model data and boilerplate code for the slice following Prismic requirements.\n\nYou will work under the slice library at <slice_library_path>, where all the slices are stored.\n\n# AVAILABLE RESOURCES\n\n<design_image_path>\n${tmpImagePath}\n</design_image_path>\n\n<slice_library_path>\n${libraryAbsPath}\n</slice_library_path>\n\n<framework>\n${framework.label}\n</framework>\n\n# AVAILABLE TOOLS\n\nYou have access to specialized Prismic MCP tools for this task:\n\n<tool name=\"mcp__prismic__how_to_model_slice\">\n<description>\nProvides detailed guidance on creating Prismic slice models, including field types, naming conventions, and best practices.\n</description>\n<when_to_use>\nCall this tool in Step 2.1 to learn how to structure the slice model data for the design you analysed.\n</when_to_use>\n</tool>\n\n<tool name=\"mcp__prismic__how_to_code_slice\">\n<description>\nProvides guidance on implementing Prismic slice components, including how to use Prismic field components, props structure, and best practices.\n</description>\n<when_to_use>\nCall this tool in Step 2.1 to learn how to properly structure the slice component with Prismic fields.\n</when_to_use>\n</tool>\n\n<tool name=\"mcp__prismic__save_slice_data\">\n<description>\nValidates and saves the slice model data to model.json. This is the ONLY way to create the model file.\n</description>\n<when_to_use>\nCall this tool in Step 2.3 after you have built the complete slice model structure in memory.\n</when_to_use>\n</tool>\n\n# TASK REQUIREMENTS\n\n## Step 1: Gather information from the design image\n1.1. Analyse the design image at <design_image_path>.\n1.2. Identify all elements in the image that should be dynamically editable (e.g., headings, paragraphs, images, links, buttons, etc.).\n1.3. List the slice directories under <slice_library_path>.\n1.4. Come up with a unique name for the new slice based on the content of the image and the slice directories.\n\n## Step 2: Model the Prismic slice\n2.1. Call mcp__prismic__how_to_model_slice to learn how to structure the model for this design.\n- Make sure the name you use for the new slice does not yet exist in the slice library at <slice_library_path>. If it does, use a different name.\n2.2. Build the complete slice JSON model data in memory based on the guidance received and the information extracted from the image.\n2.3. Call mcp__prismic__save_slice_data to save the model (DO NOT manually write model.json) in the slice library at <slice_library_path>.\n\n## Step 3: Code a boilerplate slice component based on the model\n3.1. Call mcp__prismic__how_to_code_slice to learn how to properly structure the slice component with Prismic fields.\n3.2. Update the slice component code at <slice_library_path>/index.${frameworkFileExtension}, replacing the placeholder code with boilerplate code with the following requirements:\n- Must NOT be based on existing slices or components from the codebase.\n- Must render all the Prismic components to display the fields of the slice model created at <slice_model_path>.\n- Must be a valid ${framework.label} component.\n- Must NOT have any styling/CSS. No inlines styles or classNames. Just the skeleton component structure.\n- Must NOT use any other custom component or functions from the user's codebase.\n- Avoid creating unnecessary wrapper elements, like if they only wrap a single component (e.g., <div><PrismicRichText /></div>).\n\n## Step 4: Present the newly created slice path\n4.1. Present the path to the newly created slice in the following format: <new_slice_path>${libraryAbsPath}/MyNewSlice</new_slice_path>.\n- \"MyNewSlice\" must be the name of the directory of the newly created slice.\n\n# EXAMPLE OF CORRECT EXECUTION\n\n<example>\nAssistant: Step 1.1: Analysing design image...\n[reads <design_image_path>]\n\nStep 1.2: Identifying editable content elements...\n[identifies: title field, description field, buttonText field, buttonLink field, backgroundImage field]\n\nStep 1.3: Listing slice directories under <slice_library_path>...\n[lists slice directories: Hero, Hero2, Hero3]\n\nStep 1.4: Coming up with a unique name for the new slice...\n[comes up with a unique name for the new slice: Hero4]\n\nStep 2.1: Getting Prismic modeling guidance...\n[calls mcp__prismic__how_to_model_slice]\n\nStep 2.2: Building slice model based on guidance and the information extracted...\n[creates model with title field, description field, buttonText field, buttonLink field, backgroundImage field]\n\nStep 2.3: Saving slice model...\n[calls mcp__prismic__save_slice_data]\n\nStep 3.1: Learning Prismic slice coding requirements...\n[calls mcp__prismic__how_to_code_slice]\n\nStep 3.2: Coding boilerplate slice component based on the model...\n[updates component with Prismic field components, no styling, no other components]\n\nStep 4.1: Presenting the path to the newly created slice...\n[presents <new_slice_path>${path.join(\n\t\t\t\t\t\tlibraryAbsPath,\n\t\t\t\t\t\t\"MyNewSlice\",\n\t\t\t\t\t)}</new_slice_path>]\n\n# DELIVERABLES\n- Slice model saved to <slice_library_path>/model.json using mcp__prismic__save_slice_data\n- Slice component at <slice_library_path>/index.${frameworkFileExtension} updated with boilerplate code\n- New slice path presented in the format mentioned in Step 3.1\n\nYOU ARE NOT FINISHED UNTIL YOU HAVE THESE DELIVERABLES.\n\n---\n\nFINAL REMINDERS:\n- You MUST use mcp__prismic__save_slice_data to save the model\n- You MUST call mcp__prismic__how_to_code_slice in Step 3.1\n- DO NOT ATTEMPT TO BUILD THE APPLICATION\n- START IMMEDIATELY WITH STEP 1.1 - NO PRELIMINARY ANALYSIS;`,\n\t\t\t\t\toptions: {\n\t\t\t\t\t\tcwd: libraryAbsPath,\n\t\t\t\t\t\tstderr: (data) => console.error(data),\n\t\t\t\t\t\tmodel: \"claude-haiku-4-5\",\n\t\t\t\t\t\tpermissionMode: \"bypassPermissions\",\n\t\t\t\t\t\tallowedTools: [\n\t\t\t\t\t\t\t\"Bash\",\n\t\t\t\t\t\t\t\"Read\",\n\t\t\t\t\t\t\t\"FileSearch\",\n\t\t\t\t\t\t\t\"Grep\",\n\t\t\t\t\t\t\t\"Glob\",\n\t\t\t\t\t\t\t\"Task\",\n\t\t\t\t\t\t\t\"Edit\",\n\t\t\t\t\t\t\t\"Write\",\n\t\t\t\t\t\t\t\"MultiEdit\",\n\t\t\t\t\t\t\t\"mcp__prismic__how_to_model_slice\",\n\t\t\t\t\t\t\t\"mcp__prismic__how_to_code_slice\",\n\t\t\t\t\t\t\t\"mcp__prismic__save_slice_data\",\n\t\t\t\t\t\t],\n\t\t\t\t\t\tdisallowedTools: [\n\t\t\t\t\t\t\t`Edit(**/model.json)`,\n\t\t\t\t\t\t\t`Write(**/model.json)`,\n\t\t\t\t\t\t\t\"Edit(**/mocks.json)\",\n\t\t\t\t\t\t\t\"Write(**/mocks.json)\",\n\t\t\t\t\t\t],\n\t\t\t\t\t\tenv: {\n\t\t\t\t\t\t\t...process.env,\n\t\t\t\t\t\t\tANTHROPIC_BASE_URL: API_ENDPOINTS.LlmProxyTypeService,\n\t\t\t\t\t\t\tANTHROPIC_CUSTOM_HEADERS:\n\t\t\t\t\t\t\t\t`x-prismic-token: ${authToken}\\n` +\n\t\t\t\t\t\t\t\t`x-prismic-repository: ${repository}\\n`,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tmcpServers: {\n\t\t\t\t\t\t\tprismic: {\n\t\t\t\t\t\t\t\ttype: \"stdio\",\n\t\t\t\t\t\t\t\tcommand: \"npx\",\n\t\t\t\t\t\t\t\targs: [\"-y\", \"@prismicio/mcp-server@0.0.20-alpha.6\"],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t});\n\n\t\t\t\tlet newSliceAbsPath: string | undefined;\n\n\t\t\t\tfor await (const query of queries) {\n\t\t\t\t\tswitch (query.type) {\n\t\t\t\t\t\tcase \"result\":\n\t\t\t\t\t\t\tif (query.subtype === \"success\") {\n\t\t\t\t\t\t\t\tnewSliceAbsPath = query.result.match(\n\t\t\t\t\t\t\t\t\t/<new_slice_path>(.*)<\\/new_slice_path>/s,\n\t\t\t\t\t\t\t\t)?.[1];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (!newSliceAbsPath) {\n\t\t\t\t\tthrow new Error(\"Could not find path for the newly created slice.\");\n\t\t\t\t}\n\n\t\t\t\tconst model = await readFile(\n\t\t\t\t\tpath.join(newSliceAbsPath, \"model.json\"),\n\t\t\t\t\t\"utf8\",\n\t\t\t\t);\n\n\t\t\t\tif (!model) {\n\t\t\t\t\tthrow new Error(\"Could not find model for the newly created slice.\");\n\t\t\t\t}\n\n\t\t\t\t// move the screenshot image to the new slice directory\n\t\t\t\tawait rename(\n\t\t\t\t\ttmpImagePath,\n\t\t\t\t\tpath.join(newSliceAbsPath, \"screenshot-default.png\"),\n\t\t\t\t);\n\t\t\t\tawait rm(tmpDir, { recursive: true });\n\n\t\t\t\tconst elapsedTimeSeconds = (Date.now() - startTime) / 1000;\n\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\tconsole.log(`inferSlice took ${elapsedTimeSeconds}s`);\n\n\t\t\t\treturn InferSliceResponse.parse({ slice: JSON.parse(model) });\n\t\t\t} catch (error) {\n\t\t\t\tif (tmpDir && existsSync(tmpDir)) {\n\t\t\t\t\tawait rm(tmpDir, { recursive: true });\n\t\t\t\t}\n\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t} else {\n\t\t\tconst headers = {\n\t\t\t\tAuthorization: `Bearer ${authToken}`,\n\t\t\t};\n\n\t\t\tconst searchParams = new URLSearchParams({\n\t\t\t\trepository,\n\t\t\t});\n\n\t\t\tconst url = new URL(\"./slices/infer\", API_ENDPOINTS.CustomTypeService);\n\t\t\turl.search = searchParams.toString();\n\n\t\t\tconst response = await fetch(url.toString(), {\n\t\t\t\tmethod: \"POST\",\n\t\t\t\theaders: headers,\n\t\t\t\tbody: JSON.stringify({ imageUrl }),\n\t\t\t});\n\n\t\t\tif (!response.ok) {\n\t\t\t\tthrow new Error(`Failed to infer slice: ${response.statusText}`);\n\t\t\t}\n\n\t\t\tconst json = await response.json();\n\n\t\t\treturn InferSliceResponse.parse(json);\n\t\t}\n\t}\n}\n\ntype InferSliceResponse = z.infer<typeof InferSliceResponse>;\n\nconst InferSliceResponse = z.object({\n\tslice: z.custom().transform((value, ctx) => {\n\t\tconst result = SharedSlice.decode(value);\n\t\tif (result._tag === \"Right\") {\n\t\t\treturn result.right;\n\t\t}\n\t\tctx.addIssue({\n\t\t\tcode: z.ZodIssueCode.custom,\n\t\t\tmessage: `Invalid shared slice: ${JSON.stringify(value, null, 2)}`,\n\t\t});\n\n\t\treturn z.NEVER;\n\t}),\n\tlangSmithUrl: z.string().url().optional(),\n});\n\nfunction updateCRCustomType(\n\targs: { customType: LinkCustomType } & CustomTypeFieldIdChangedMeta,\n): LinkCustomType {\n\tconst previousPath = getPathIds(args.previousPath);\n\tconst newPath = getPathIds(args.newPath);\n\n\tif (!previousPath.customTypeId || !newPath.customTypeId) {\n\t\tthrow new Error(\n\t\t\t`Could not find a customtype id in previousPath (${args.previousPath.join(\n\t\t\t\t\".\",\n\t\t\t)}) and/or newPath (${args.newPath.join(\n\t\t\t\t\".\",\n\t\t\t)}), which should not be possible.`,\n\t\t);\n\t}\n\n\tif (!previousPath.fieldId || !newPath.fieldId) {\n\t\tthrow new Error(\n\t\t\t`Could not find a field id in previousPath (${args.previousPath.join(\n\t\t\t\t\".\",\n\t\t\t)}) and/or newPath (${args.newPath.join(\n\t\t\t\t\".\",\n\t\t\t)}), which should not be possible.`,\n\t\t);\n\t}\n\n\tconst customType = shallowCloneIfObject(args.customType);\n\n\tif (typeof customType === \"string\") {\n\t\t// Legacy format support, we don't have anything to update here.\n\t\treturn customType;\n\t}\n\n\tconst matchedCustomTypeId = customType.id === previousPath.customTypeId;\n\n\treturn {\n\t\t...customType,\n\t\tfields: customType.fields.map((fieldArg) => {\n\t\t\tconst customTypeField = shallowCloneIfObject(fieldArg);\n\n\t\t\t// Regular field\n\t\t\tif (typeof customTypeField === \"string\") {\n\t\t\t\tif (\n\t\t\t\t\tmatchedCustomTypeId &&\n\t\t\t\t\tcustomTypeField === previousPath.fieldId &&\n\t\t\t\t\tcustomTypeField !== newPath.fieldId\n\t\t\t\t) {\n\t\t\t\t\t// The id of the field has changed.\n\t\t\t\t\treturn newPath.fieldId;\n\t\t\t\t}\n\n\t\t\t\treturn customTypeField;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tmatchedCustomTypeId &&\n\t\t\t\tcustomTypeField.id === previousPath.fieldId &&\n\t\t\t\tcustomTypeField.id !== newPath.fieldId\n\t\t\t) {\n\t\t\t\t// The id of the field has changed. We don't exit return because there\n\t\t\t\t// might be other fields further down in nested custom types or groups\n\t\t\t\t// that need to be updated.\n\t\t\t\tcustomTypeField.id = newPath.fieldId;\n\t\t\t}\n\n\t\t\t// Group field\n\t\t\tif (\"fields\" in customTypeField) {\n\t\t\t\tif (\n\t\t\t\t\t!previousPath.groupId &&\n\t\t\t\t\t!newPath.groupId &&\n\t\t\t\t\tcustomTypeField.id === previousPath.fieldId &&\n\t\t\t\t\tcustomTypeField.id !== newPath.fieldId\n\t\t\t\t) {\n\t\t\t\t\t// Only the id of the group has changed. Group id is not defined, so\n\t\t\t\t\t// we can return early.\n\t\t\t\t\treturn newPath.fieldId;\n\t\t\t\t}\n\n\t\t\t\tconst matchedGroupId = customTypeField.id === previousPath.groupId;\n\n\t\t\t\tif (\n\t\t\t\t\tpreviousPath.groupId &&\n\t\t\t\t\tnewPath.groupId &&\n\t\t\t\t\tmatchedGroupId &&\n\t\t\t\t\tcustomTypeField.id !== newPath.groupId\n\t\t\t\t) {\n\t\t\t\t\t// The id of the group field has changed, so we update it. We don't\n\t\t\t\t\t// return because there are group fields that may need to be updated.\n\t\t\t\t\tcustomTypeField.id = newPath.groupId;\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\t...customTypeField,\n\t\t\t\t\tfields: customTypeField.fields.map((groupFieldArg) => {\n\t\t\t\t\t\tconst groupField = shallowCloneIfObject(groupFieldArg);\n\n\t\t\t\t\t\t// Regular field inside a group field\n\t\t\t\t\t\tif (typeof groupField === \"string\") {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tmatchedGroupId &&\n\t\t\t\t\t\t\t\tgroupField === previousPath.fieldId &&\n\t\t\t\t\t\t\t\tgroupField !== newPath.fieldId\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t// The id of the field inside the group has changed.\n\t\t\t\t\t\t\t\treturn newPath.fieldId;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\treturn groupField;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Content relationship field inside a group field\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...groupField,\n\t\t\t\t\t\t\tfields: updateContentRelationshipFields({\n\t\t\t\t\t\t\t\tcustomtypes: groupField.customtypes,\n\t\t\t\t\t\t\t\tpreviousPath,\n\t\t\t\t\t\t\t\tnewPath,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t};\n\t\t\t\t\t}),\n\t\t\t\t};\n\t\t\t}\n\n\t\t\t// Content relationship field\n\t\t\treturn {\n\t\t\t\t...customTypeField,\n\t\t\t\tcustomtypes: updateContentRelationshipFields({\n\t\t\t\t\tcustomtypes: customTypeField.customtypes,\n\t\t\t\t\tpreviousPath,\n\t\t\t\t\tnewPath,\n\t\t\t\t}),\n\t\t\t};\n\t\t}),\n\t};\n}\n\nfunction updateContentRelationshipFields(args: {\n\tcustomtypes: readonly (\n\t\t| string\n\t\t| {\n\t\t\t\tid: string;\n\t\t\t\tfields: readonly (string | { id: string; fields: readonly string[] })[];\n\t\t }\n\t)[];\n\tpreviousPath: CrUpdatePathIds;\n\tnewPath: CrUpdatePathIds;\n}) {\n\tconst { customtypes, previousPath, newPath } = args;\n\n\treturn customtypes.map((nestedCtArg) => {\n\t\tconst nestedCt = shallowCloneIfObject(nestedCtArg);\n\n\t\tif (\n\t\t\ttypeof nestedCt === \"string\" ||\n\t\t\t// Since we are entering a new custom type, if the previous id\n\t\t\t// doesn't match, we can return early, because it's not the\n\t\t\t// custom type we are looking for.\n\t\t\tnestedCt.id !== previousPath.customTypeId\n\t\t) {\n\t\t\treturn nestedCt;\n\t\t}\n\n\t\treturn {\n\t\t\t...nestedCt,\n\t\t\tfields: nestedCt.fields.map((nestedCtFieldArg) => {\n\t\t\t\tconst nestedCtField = shallowCloneIfObject(nestedCtFieldArg);\n\n\t\t\t\t// Regular field\n\t\t\t\tif (typeof nestedCtField === \"string\") {\n\t\t\t\t\tif (\n\t\t\t\t\t\tnestedCtField === previousPath.fieldId &&\n\t\t\t\t\t\tnestedCtField !== newPath.fieldId\n\t\t\t\t\t) {\n\t\t\t\t\t\t// The id of the field has changed.\n\t\t\t\t\t\treturn newPath.fieldId;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn nestedCtField;\n\t\t\t\t}\n\n\t\t\t\t// Group field\n\n\t\t\t\tif (\n\t\t\t\t\tnestedCtField.id === previousPath.fieldId &&\n\t\t\t\t\tnestedCtField.id !== newPath.fieldId\n\t\t\t\t) {\n\t\t\t\t\t// The id of the field has changed.\n\t\t\t\t\tnestedCtField.id = newPath.fieldId;\n\t\t\t\t}\n\n\t\t\t\t// Further down the path, the field can only be a group field. So if we have\n\t\t\t\t// no group id defined, no need to continue.\n\t\t\t\tif (\n\t\t\t\t\t!previousPath.groupId ||\n\t\t\t\t\t!newPath.groupId ||\n\t\t\t\t\tnestedCtField.id !== previousPath.groupId\n\t\t\t\t) {\n\t\t\t\t\treturn nestedCtField;\n\t\t\t\t}\n\n\t\t\t\tif (nestedCtField.id !== newPath.groupId) {\n\t\t\t\t\t// The id of the group has changed.\n\t\t\t\t\tnestedCtField.id = newPath.groupId;\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\t...nestedCtField,\n\t\t\t\t\tfields: nestedCtField.fields.map((nestedCtGroupFieldId) => {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tnestedCtGroupFieldId === previousPath.fieldId &&\n\t\t\t\t\t\t\tnestedCtGroupFieldId !== newPath.fieldId\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t// The id of the field inside the group has changed.\n\t\t\t\t\t\t\treturn newPath.fieldId;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn nestedCtGroupFieldId;\n\t\t\t\t\t}),\n\t\t\t\t};\n\t\t\t}),\n\t\t};\n\t});\n}\n\n/**\n * Update the Content Relationship API IDs of a single field. The change is\n * determined by the `previousPath` and `newPath` properties.\n */\nfunction updateFieldContentRelationships<\n\tT extends UID | NestableWidget | Group | NestedGroup,\n>(args: { field: T } & CustomTypeFieldIdChangedMeta): T {\n\tconst { field, ...updateMeta } = args;\n\tif (\n\t\tfield.type !== \"Link\" ||\n\t\tfield.config?.select !== \"document\" ||\n\t\t!field.config?.customtypes\n\t) {\n\t\t// not a content relationship field\n\t\treturn field;\n\t}\n\n\tconst newCustomTypes = field.config.customtypes.map((customType) => {\n\t\treturn updateCRCustomType({ ...updateMeta, customType });\n\t});\n\n\treturn {\n\t\t...field,\n\t\tconfig: { ...field.config, customtypes: newCustomTypes },\n\t};\n}\n\nexport function updateCustomTypeContentRelationships(\n\targs: {\n\t\tmodels: { model: CustomType }[];\n\t\tonUpdate: (model: { previousModel: CustomType; model: CustomType }) => void;\n\t} & CustomTypeFieldIdChangedMeta,\n): void {\n\tconst { models, previousPath, newPath, onUpdate } = args;\n\n\tfor (const { model: customType } of models) {\n\t\tconst updatedCustomType = traverseCustomType({\n\t\t\tcustomType,\n\t\t\tonField: ({ field }) => {\n\t\t\t\treturn updateFieldContentRelationships({\n\t\t\t\t\tfield,\n\t\t\t\t\tpreviousPath,\n\t\t\t\t\tnewPath,\n\t\t\t\t});\n\t\t\t},\n\t\t});\n\n\t\tif (!isEqualModel(customType, updatedCustomType)) {\n\t\t\tonUpdate({ model: updatedCustomType, previousModel: customType });\n\t\t}\n\t}\n}\n\nexport function updateSharedSliceContentRelationships(\n\targs: {\n\t\tmodels: { model: SharedSlice }[];\n\t\tonUpdate: (model: {\n\t\t\tpreviousModel: SharedSlice;\n\t\t\tmodel: SharedSlice;\n\t\t}) => void;\n\t} & CustomTypeFieldIdChangedMeta,\n): void {\n\tconst { models, previousPath, newPath, onUpdate } = args;\n\n\tfor (const { model: slice } of models) {\n\t\tconst updateSlice = traverseSharedSlice({\n\t\t\tpath: [],\n\t\t\tslice,\n\t\t\tonField: ({ field }) => {\n\t\t\t\treturn updateFieldContentRelationships({\n\t\t\t\t\tfield,\n\t\t\t\t\tpreviousPath,\n\t\t\t\t\tnewPath,\n\t\t\t\t});\n\t\t\t},\n\t\t});\n\n\t\tif (!isEqualModel(slice, updateSlice)) {\n\t\t\tonUpdate({ model: updateSlice, previousModel: slice });\n\t\t}\n\t}\n}\n\ninterface CrUpdatePathIds {\n\tcustomTypeId: string;\n\tgroupId: string | undefined;\n\tfieldId: string;\n}\n\nfunction getPathIds(path: PathWithCustomType): CrUpdatePathIds {\n\tif (path.length < 2) {\n\t\tthrow new Error(\n\t\t\t`Unexpected path length ${\n\t\t\t\tpath.length\n\t\t\t}. Expected at least 2 segments (got: ${path.join(\".\")}).`,\n\t\t);\n\t}\n\n\tconst [customTypeId, groupOrFieldId, fieldId] = path;\n\n\treturn {\n\t\tcustomTypeId,\n\t\t/**\n\t\t * Id of a changed group. If it's defined, it means that a group or a field\n\t\t * inside a group had its API ID renamed. It's defined when the path has a\n\t\t * third element (e.g. `[\"customtypeA\", \"groupA\", \"fieldA\"]`).\n\t\t */\n\t\tgroupId: fieldId ? groupOrFieldId : undefined,\n\t\tfieldId: fieldId || groupOrFieldId,\n\t};\n}\n\nfunction isEqualModel<T extends CustomType | SharedSlice>(\n\tmodelA: T,\n\tmodelB: T,\n): boolean {\n\treturn JSON.stringify(modelA) === JSON.stringify(modelB);\n}\n\nfunction shallowCloneIfObject<T>(value: T): T {\n\tif (typeof value === \"object\") {\n\t\treturn { ...value };\n\t}\n\n\treturn value;\n}\n"],"names":["errors","_a","queryClaude","query","path"],"mappings":";;;;;;;;;;;;;;;;;AAuIM,MAAO,2BAA2B,YAAW;AAAA,EAClD,MAAM,wBAAqB;;AAC1B,6BAAyB,KAAK,wBAAwB;AAEtD,UAAM,aAAa,MAAM,KAAK,yBAAyB,SACtD,4BACA,MAAS;AAEV,UAAM,EAAE,MAAM,OAAA,IAAW,iBACxB,EAAE,KAAK;AAAA,MACN,KAAK,EAAE,MAAM,EAAE,MAAM;AAAA,IAAA,CACrB,GACD,UAAU;AAGX,WAAO;AAAA,MACN,OAAK,UAAK,CAAC,MAAN,mBAAS,QAAO,CAAA;AAAA,MACrB;AAAA,IAAA;AAAA,EAEF;AAAA,EAEA,MAAM,mBACL,MAA+C;AAE/C,6BAAyB,KAAK,wBAAwB;AAEtD,UAAM,MAAsD;AAAA,MAC3D,QAAQ,CAAA;AAAA,MACR,QAAQ,CAAA;AAAA,IAAA;AAGT,UAAM,EAAE,KAAK,OAAA,IAAW,MAAM,KAAK,sBAAA;AACnC,QAAI,SAAS,CAAC,GAAG,IAAI,QAAQ,GAAG,MAAM;AAEtC,QAAI,KAAK;AACR,iBAAW,MAAM,KAAK;AACrB,cAAM,EAAE,OAAO,QAAAA,QAAAA,IAAW,MAAM,KAAK,eAAe,EAAE,IAAI;AAC1D,YAAI,SAAS,CAAC,GAAG,IAAI,QAAQ,GAAGA,OAAM;AAEtC,YAAI,UAAU,CAAC,QAAQ,KAAK,WAAW,MAAM,SAAS;AACrD,cAAI,OAAO,KAAK,EAAE,MAAA,CAAO;AAAA,QAC1B;AAAA,MACD;AAAA,IACD;AAEA,WAAO;AAAA,EACR;AAAA,EAEA,MAAM,iBACL,MAA8B;AAE9B,6BAAyB,KAAK,wBAAwB;AAEtD,UAAM,aAAa,M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c,gBAAgB,OAAO,IAAIA;AAEhD,SAAO;AAAA,IACN;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMA,SAAS,UAAU,iBAAiB;AAAA,IACpC,SAAS,WAAW;AAAA,EAAA;AAEtB;AAEA,SAAS,aACR,QACA,QAAS;AAET,SAAO,KAAK,UAAU,MAAM,MAAM,KAAK,UAAU,MAAM;AACxD;AAEA,SAAS,qBAAwB,OAAQ;AACxC,MAAI,OAAO,UAAU,UAAU;AAC9B,WAAO,EAAE,GAAG,MAAA;AAAA,EACb;AAEA,SAAO;AACR;"}
1
+ {"version":3,"file":"CustomTypesManager.js","sources":["../../../../src/managers/customTypes/CustomTypesManager.ts"],"sourcesContent":["import * as t from \"io-ts\";\nimport * as prismicCustomTypesClient from \"@prismicio/custom-types-client\";\nimport {\n\tCustomType,\n\tGroup,\n\tLinkConfig,\n\tNestableWidget,\n\tNestedGroup,\n\tSharedSlice,\n\tUID,\n\ttraverseCustomType,\n\ttraverseSharedSlice,\n} from \"@prismicio/types-internal/lib/customtypes\";\nimport {\n\tCallHookReturnType,\n\tCustomTypeCreateHook,\n\tCustomTypeCreateHookData,\n\tCustomTypeReadHookData,\n\tCustomTypeRenameHook,\n\tCustomTypeRenameHookData,\n\tCustomTypeUpdateHook,\n\tCustomTypeUpdateHookData,\n\tHookError,\n} from \"@slicemachine/plugin-kit\";\nimport { z } from \"zod\";\nimport { query as queryClaude } from \"@anthropic-ai/claude-agent-sdk\";\n\nimport { DecodeError } from \"../../lib/DecodeError\";\nimport { assertPluginsInitialized } from \"../../lib/assertPluginsInitialized\";\nimport { decodeHookResult } from \"../../lib/decodeHookResult\";\nimport fetch from \"../../lib/fetch\";\n\nimport { OnlyHookErrors } from \"../../types\";\nimport { API_ENDPOINTS } from \"../../constants/API_ENDPOINTS\";\nimport { SLICE_MACHINE_USER_AGENT } from \"../../constants/SLICE_MACHINE_USER_AGENT\";\nimport { UnauthorizedError } from \"../../errors\";\nimport { mkdtemp, readFile, rename, rm, writeFile } from \"fs/promises\";\nimport { tmpdir } from \"os\";\nimport path from \"path\";\nimport { randomUUID } from \"crypto\";\nimport { existsSync } from \"fs\";\n\nimport { BaseManager } from \"../BaseManager\";\nimport { CustomTypeFormat } from \"./types\";\n\ntype SliceMachineManagerReadCustomTypeLibraryReturnType = {\n\tids: string[];\n\terrors: (DecodeError | HookError)[];\n};\n\ntype CustomTypesManagerReadAllCustomTypesArgs = {\n\tformat: CustomTypeFormat;\n};\n\ntype SliceMachineManagerReadAllCustomTypeReturnType = {\n\tmodels: { model: CustomType }[];\n\terrors: (DecodeError | HookError)[];\n};\n\ntype SliceMachineManagerReadCustomTypeReturnType = {\n\tmodel: CustomType | undefined;\n\terrors: (DecodeError | HookError)[];\n};\n\ntype SliceMachineManagerPushCustomTypeArgs = {\n\tid: string;\n\tuserAgent?: string;\n};\n\ntype SliceMachineManagerReadCustomTypeMocksConfigArgs = {\n\tcustomTypeID: string;\n};\n\ntype SliceMachineManagerReadCustomTypeMocksConfigArgsReturnType = {\n\t// TODO\n\tmocksConfig?: Record<string, unknown>;\n\terrors: HookError[];\n};\n\ntype SliceMachineManagerUpdateCustomTypeMocksConfigArgs = {\n\tcustomTypeID: string;\n\t// TODO\n\tmocksConfig: Record<string, unknown>;\n};\n\n/** `[field]` or `[group, field]` – path **inside** the Custom Type */\ntype PathWithoutCustomType = [string] | [string, string];\n\ntype SliceMachineManagerUpdateCustomTypeFieldIdChanged = {\n\t/**\n\t * Previous path of the changed field, excluding the custom type id. Can be\n\t * used to identify the field that had an API ID rename (e.g. [\"fieldA\"] or\n\t * [\"groupA\", \"fieldA\"])\n\t */\n\tpreviousPath: PathWithoutCustomType;\n\t/**\n\t * New path of the changed field, excluding the custom type id. Can be used to\n\t * identify the field that had an API ID rename (e.g. [\"fieldB\"] or [\"groupA\",\n\t * \"fieldB\"])\n\t */\n\tnewPath: PathWithoutCustomType;\n};\n\ntype SliceMachineManagerUpdateCustomTypeArgs = CustomTypeUpdateHookData & {\n\tupdateMeta?: {\n\t\tfieldIdChanged?: SliceMachineManagerUpdateCustomTypeFieldIdChanged;\n\t};\n};\n\ntype SliceMachineManagerUpdateCustomTypeMocksConfigArgsReturnType = {\n\terrors: HookError[];\n};\n\ntype CustomTypesMachineManagerDeleteCustomTypeArgs = {\n\tid: string;\n};\n\ntype CustomTypesMachineManagerDeleteCustomTypeReturnType = {\n\terrors: (DecodeError | HookError)[];\n};\n\ntype CustomTypesMachineManagerUpdateCustomTypeReturnType = {\n\terrors: (DecodeError | HookError)[];\n};\n\n/** `[ct, field]` or `[ct, group, field]` – path **with** Custom Type ID */\ntype PathWithCustomType = [string, string] | [string, string, string];\n\ntype CustomTypeFieldIdChangedMeta = {\n\tpreviousPath: PathWithCustomType;\n\tnewPath: PathWithCustomType;\n};\n\ntype LinkCustomType = NonNullable<LinkConfig[\"customtypes\"]>[number];\n\nexport class CustomTypesManager extends BaseManager {\n\tasync readCustomTypeLibrary(): Promise<SliceMachineManagerReadCustomTypeLibraryReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type-library:read\",\n\t\t\tundefined,\n\t\t);\n\t\tconst { data, errors } = decodeHookResult(\n\t\t\tt.type({\n\t\t\t\tids: t.array(t.string),\n\t\t\t}),\n\t\t\thookResult,\n\t\t);\n\n\t\treturn {\n\t\t\tids: data[0]?.ids || [],\n\t\t\terrors,\n\t\t};\n\t}\n\n\tasync readAllCustomTypes(\n\t\targs?: CustomTypesManagerReadAllCustomTypesArgs,\n\t): Promise<SliceMachineManagerReadAllCustomTypeReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst res: SliceMachineManagerReadAllCustomTypeReturnType = {\n\t\t\tmodels: [],\n\t\t\terrors: [],\n\t\t};\n\n\t\tconst { ids, errors } = await this.readCustomTypeLibrary();\n\t\tres.errors = [...res.errors, ...errors];\n\n\t\tif (ids) {\n\t\t\tfor (const id of ids) {\n\t\t\t\tconst { model, errors } = await this.readCustomType({ id });\n\t\t\t\tres.errors = [...res.errors, ...errors];\n\n\t\t\t\tif (model && (!args || args.format === model.format)) {\n\t\t\t\t\tres.models.push({ model });\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn res;\n\t}\n\n\tasync createCustomType(\n\t\targs: CustomTypeCreateHookData,\n\t): Promise<OnlyHookErrors<CallHookReturnType<CustomTypeCreateHook>>> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:create\",\n\t\t\targs,\n\t\t);\n\n\t\treturn {\n\t\t\terrors: hookResult.errors,\n\t\t};\n\t}\n\n\tasync readCustomType(\n\t\targs: CustomTypeReadHookData,\n\t): Promise<SliceMachineManagerReadCustomTypeReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:read\",\n\t\t\targs,\n\t\t);\n\t\tconst { data, errors } = decodeHookResult(\n\t\t\tt.type({\n\t\t\t\tmodel: CustomType,\n\t\t\t}),\n\t\t\thookResult,\n\t\t);\n\n\t\treturn {\n\t\t\tmodel: data[0]?.model,\n\t\t\terrors,\n\t\t};\n\t}\n\n\t/**\n\t * Update the Content Relationship API IDs for all existing custom types and\n\t * slices. The change is determined by properties inside the `updateMeta`\n\t * property.\n\t */\n\tprivate async updateContentRelationships(\n\t\targs: {\n\t\t\tmodel: CustomType;\n\t\t} & SliceMachineManagerUpdateCustomTypeFieldIdChanged,\n\t): Promise<\n\t\tOnlyHookErrors<CallHookReturnType<CustomTypeUpdateHook>> & {\n\t\t\trollback?: () => Promise<void>;\n\t\t}\n\t> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst {\n\t\t\tmodel,\n\t\t\tpreviousPath: previousFieldPath,\n\t\t\tnewPath: newFieldPath,\n\t\t} = args;\n\n\t\tif (previousFieldPath.join(\".\") !== newFieldPath.join(\".\")) {\n\t\t\tconst { id: ctId } = model;\n\t\t\tconst previousPath: PathWithCustomType = [ctId, ...previousFieldPath];\n\t\t\tconst newPath: PathWithCustomType = [ctId, ...newFieldPath];\n\n\t\t\tconst crUpdates: {\n\t\t\t\tupdatePromise: Promise<{ errors: HookError[] }>;\n\t\t\t\trollback: () => void;\n\t\t\t}[] = [];\n\n\t\t\t// Find existing content relationships that link to the renamed field id in\n\t\t\t// any custom type and update them to use the new one.\n\t\t\tconst customTypes = await this.readAllCustomTypes();\n\n\t\t\tupdateCustomTypeContentRelationships({\n\t\t\t\tmodels: customTypes.models,\n\t\t\t\tonUpdate: ({ previousModel, model: updatedModel }) => {\n\t\t\t\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\t\t\t\tcrUpdates.push({\n\t\t\t\t\t\tupdatePromise: this.sliceMachinePluginRunner?.callHook(\n\t\t\t\t\t\t\t\"custom-type:update\",\n\t\t\t\t\t\t\t{ model: updatedModel },\n\t\t\t\t\t\t),\n\t\t\t\t\t\trollback: () => {\n\t\t\t\t\t\t\tthis.sliceMachinePluginRunner?.callHook(\"custom-type:update\", {\n\t\t\t\t\t\t\t\tmodel: previousModel,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t},\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\tpreviousPath,\n\t\t\t\tnewPath,\n\t\t\t});\n\n\t\t\t// Find existing slice with content relationships that link to the renamed\n\t\t\t// field id in all libraries and update them to use the new one.\n\t\t\tconst { libraries } = await this.slices.readAllSliceLibraries();\n\n\t\t\tfor (const library of libraries) {\n\t\t\t\tconst slices = await this.slices.readAllSlicesForLibrary({\n\t\t\t\t\tlibraryID: library.libraryID,\n\t\t\t\t});\n\n\t\t\t\tupdateSharedSliceContentRelationships({\n\t\t\t\t\tmodels: slices.models,\n\t\t\t\t\tonUpdate: ({ previousModel, model: updatedModel }) => {\n\t\t\t\t\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\t\t\t\t\tcrUpdates.push({\n\t\t\t\t\t\t\tupdatePromise: this.sliceMachinePluginRunner?.callHook(\n\t\t\t\t\t\t\t\t\"slice:update\",\n\t\t\t\t\t\t\t\t{ libraryID: library.libraryID, model: updatedModel },\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\trollback: () => {\n\t\t\t\t\t\t\t\tthis.sliceMachinePluginRunner?.callHook(\"slice:update\", {\n\t\t\t\t\t\t\t\t\tlibraryID: library.libraryID,\n\t\t\t\t\t\t\t\t\tmodel: previousModel,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t});\n\t\t\t\t\t},\n\t\t\t\t\tpreviousPath,\n\t\t\t\t\tnewPath,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// Process all the Content Relationship updates at once.\n\t\t\tconst crUpdatesResult = await Promise.all(\n\t\t\t\tcrUpdates.map((update) => update.updatePromise),\n\t\t\t);\n\n\t\t\tif (crUpdatesResult.some((result) => result.errors.length > 0)) {\n\t\t\t\treturn {\n\t\t\t\t\terrors: crUpdatesResult.flatMap((result) => result.errors),\n\t\t\t\t\trollback: async () => {\n\t\t\t\t\t\tawait Promise.all(crUpdates.map((update) => update.rollback()));\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\treturn { errors: [] };\n\t}\n\n\tasync updateCustomType(\n\t\targs: SliceMachineManagerUpdateCustomTypeArgs,\n\t): Promise<CustomTypesMachineManagerUpdateCustomTypeReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\t\tconst { model } = args;\n\t\tconst { fieldIdChanged } = args.updateMeta ?? {};\n\n\t\tlet previousCustomType: CustomType | undefined;\n\n\t\tif (fieldIdChanged) {\n\t\t\tconst customTypeRead = await this.readCustomType({ id: model.id });\n\n\t\t\tif (customTypeRead.errors.length > 0) {\n\t\t\t\treturn { errors: customTypeRead.errors };\n\t\t\t}\n\t\t\tif (!customTypeRead.model) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`readCustomType succeeded reading custom type ${model.id} but model is undefined.`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tpreviousCustomType = customTypeRead.model;\n\t\t}\n\n\t\tconst customTypeUpdateResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:update\",\n\t\t\t{ model },\n\t\t);\n\n\t\tif (customTypeUpdateResult.errors.length > 0) {\n\t\t\treturn { errors: customTypeUpdateResult.errors };\n\t\t}\n\n\t\tif (previousCustomType && fieldIdChanged) {\n\t\t\tconst crUpdateResult = await this.updateContentRelationships({\n\t\t\t\t...fieldIdChanged,\n\t\t\t\tmodel: previousCustomType,\n\t\t\t});\n\n\t\t\tif (crUpdateResult.errors.length > 0) {\n\t\t\t\t// put the previous custom type back\n\t\t\t\tawait this.sliceMachinePluginRunner?.callHook(\"custom-type:update\", {\n\t\t\t\t\tmodel: previousCustomType,\n\t\t\t\t});\n\t\t\t\t// revert the content relationships updates\n\t\t\t\tawait crUpdateResult.rollback?.();\n\n\t\t\t\treturn { errors: crUpdateResult.errors };\n\t\t\t}\n\t\t}\n\n\t\treturn { errors: [] };\n\t}\n\n\tasync renameCustomType(\n\t\targs: CustomTypeRenameHookData,\n\t): Promise<OnlyHookErrors<CallHookReturnType<CustomTypeRenameHook>>> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:rename\",\n\t\t\targs,\n\t\t);\n\n\t\treturn {\n\t\t\terrors: hookResult.errors,\n\t\t};\n\t}\n\n\tasync deleteCustomType(\n\t\targs: CustomTypesMachineManagerDeleteCustomTypeArgs,\n\t): Promise<CustomTypesMachineManagerDeleteCustomTypeReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst { model, errors: readCustomTypeErrors } = await this.readCustomType({\n\t\t\tid: args.id,\n\t\t});\n\n\t\tif (model) {\n\t\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\t\"custom-type:delete\",\n\t\t\t\t{ model },\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\terrors: hookResult.errors,\n\t\t\t};\n\t\t} else {\n\t\t\treturn {\n\t\t\t\terrors: readCustomTypeErrors,\n\t\t\t};\n\t\t}\n\t}\n\n\tasync pushCustomType(\n\t\targs: SliceMachineManagerPushCustomTypeArgs,\n\t): Promise<void> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst authenticationToken = await this.user.getAuthenticationToken();\n\t\tconst repositoryName = await this.project.getResolvedRepositoryName();\n\n\t\t// TODO: Handle errors\n\t\tconst { model } = await this.readCustomType({ id: args.id });\n\n\t\tif (model) {\n\t\t\t// TODO: Create a single shared client.\n\t\t\tconst client = prismicCustomTypesClient.createClient({\n\t\t\t\tendpoint: API_ENDPOINTS.PrismicModels,\n\t\t\t\trepositoryName,\n\t\t\t\ttoken: authenticationToken,\n\t\t\t\tfetch,\n\t\t\t\tfetchOptions: {\n\t\t\t\t\theaders: {\n\t\t\t\t\t\t\"User-Agent\": args.userAgent || SLICE_MACHINE_USER_AGENT,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t});\n\n\t\t\ttry {\n\t\t\t\t// Check if Custom Type already exists on the repository.\n\t\t\t\tawait client.getCustomTypeByID(args.id);\n\n\t\t\t\t// If it exists on the repository, update it.\n\t\t\t\tawait client.updateCustomType(model);\n\t\t\t} catch (error) {\n\t\t\t\tif (error instanceof prismicCustomTypesClient.NotFoundError) {\n\t\t\t\t\t// If it doesn't exist on the repository, insert it.\n\t\t\t\t\tawait client.insertCustomType(model);\n\t\t\t\t} else if (error instanceof prismicCustomTypesClient.ForbiddenError) {\n\t\t\t\t\tthrow new UnauthorizedError(\n\t\t\t\t\t\t\"You do not have access to push types to this Prismic repository.\",\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcause: error,\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// TODO: Remove\n\tasync readCustomTypeMocksConfig(\n\t\targs: SliceMachineManagerReadCustomTypeMocksConfigArgs,\n\t): Promise<SliceMachineManagerReadCustomTypeMocksConfigArgsReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:asset:read\",\n\t\t\t{\n\t\t\t\tcustomTypeID: args.customTypeID,\n\t\t\t\tassetID: \"mocks.config.json\",\n\t\t\t},\n\t\t);\n\t\tconst data = hookResult.data[0]?.data;\n\n\t\t// TODO: Validate the returned data.\n\n\t\tif (data) {\n\t\t\treturn {\n\t\t\t\tmocksConfig: JSON.parse(data.toString()),\n\t\t\t\terrors: hookResult.errors,\n\t\t\t};\n\t\t} else {\n\t\t\treturn {\n\t\t\t\tmocksConfig: undefined,\n\t\t\t\terrors: hookResult.errors,\n\t\t\t};\n\t\t}\n\t}\n\n\t// TODO: Remove\n\tasync updateCustomTypeMocksConfig(\n\t\targs: SliceMachineManagerUpdateCustomTypeMocksConfigArgs,\n\t): Promise<SliceMachineManagerUpdateCustomTypeMocksConfigArgsReturnType> {\n\t\tassertPluginsInitialized(this.sliceMachinePluginRunner);\n\n\t\tconst hookResult = await this.sliceMachinePluginRunner.callHook(\n\t\t\t\"custom-type:asset:update\",\n\t\t\t{\n\t\t\t\tcustomTypeID: args.customTypeID,\n\t\t\t\tasset: {\n\t\t\t\t\tid: \"mocks.config.json\",\n\t\t\t\t\tdata: Buffer.from(JSON.stringify(args.mocksConfig, null, \"\\t\")),\n\t\t\t\t},\n\t\t\t},\n\t\t);\n\n\t\treturn {\n\t\t\terrors: hookResult.errors,\n\t\t};\n\t}\n\n\tasync fetchRemoteCustomTypes(): Promise<CustomType[]> {\n\t\tconst authenticationToken = await this.user.getAuthenticationToken();\n\t\tconst repositoryName = await this.project.getResolvedRepositoryName();\n\n\t\tconst client = prismicCustomTypesClient.createClient({\n\t\t\tendpoint: API_ENDPOINTS.PrismicModels,\n\t\t\trepositoryName,\n\t\t\ttoken: authenticationToken,\n\t\t\tfetch,\n\t\t\tfetchOptions: {\n\t\t\t\theaders: {\n\t\t\t\t\t\"User-Agent\": SLICE_MACHINE_USER_AGENT,\n\t\t\t\t},\n\t\t\t},\n\t\t});\n\n\t\treturn await client.getAllCustomTypes();\n\t}\n\n\tasync inferSlice(\n\t\targs: { imageUrl: string } & (\n\t\t\t| { source: \"upload\" }\n\t\t\t| { source: \"figma\"; libraryID: string }\n\t\t),\n\t): Promise<InferSliceResponse> {\n\t\tconst { source, imageUrl } = args;\n\n\t\tconst exp = await this.telemetry.getExperimentVariant(\"llm-proxy-access\");\n\t\tif (exp?.value !== \"on\") {\n\t\t\tthrow new Error(\"LLM proxy access is not enabled.\");\n\t\t}\n\t\tconst { llmProxyUrl } = z\n\t\t\t.object({ llmProxyUrl: z.string() })\n\t\t\t.parse(exp.payload);\n\n\t\tconst authToken = await this.user.getAuthenticationToken();\n\t\tconst repository = await this.project.getResolvedRepositoryName();\n\n\t\tif (source === \"figma\") {\n\t\t\tconst { libraryID } = args;\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.log(`inferSlice started`);\n\t\t\tconst startTime = Date.now();\n\n\t\t\tlet tmpDir: string | undefined;\n\t\t\ttry {\n\t\t\t\tconst config = await this.project.getSliceMachineConfig();\n\n\t\t\t\tlet framework:\n\t\t\t\t\t| { type: \"nextjs\" | \"nuxt\" | \"sveltekit\"; label: string }\n\t\t\t\t\t| undefined;\n\t\t\t\tif (config.adapter === \"@slicemachine/adapter-next\") {\n\t\t\t\t\tframework = { type: \"nextjs\", label: \"Next.js (React)\" };\n\t\t\t\t} else if (\n\t\t\t\t\tconfig.adapter === \"@slicemachine/adapter-nuxt\" ||\n\t\t\t\t\tconfig.adapter === \"@slicemachine/adapter-nuxt2\"\n\t\t\t\t) {\n\t\t\t\t\tframework = { type: \"nuxt\", label: \"Nuxt (Vue)\" };\n\t\t\t\t} else if (config.adapter === \"@slicemachine/adapter-sveltekit\") {\n\t\t\t\t\tframework = { type: \"sveltekit\", label: \"SvelteKit (Svelte)\" };\n\t\t\t\t}\n\n\t\t\t\tif (!framework) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\"Could not determine framework from Slice Machine config.\",\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tlet frameworkFileExtension: string | undefined;\n\t\t\t\tif (framework.type === \"nextjs\") {\n\t\t\t\t\tframeworkFileExtension = \"tsx\";\n\t\t\t\t} else if (framework.type === \"nuxt\") {\n\t\t\t\t\tframeworkFileExtension = \"vue\";\n\t\t\t\t} else if (framework.type === \"sveltekit\") {\n\t\t\t\t\tframeworkFileExtension = \"svelte\";\n\t\t\t\t}\n\n\t\t\t\tif (!frameworkFileExtension) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\"Could not determine framework from Slice Machine config.\",\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tconst projectRoot = await this.project.getRoot();\n\t\t\t\tconst libraryAbsPath = path.join(projectRoot, libraryID);\n\n\t\t\t\ttmpDir = await mkdtemp(\n\t\t\t\t\tpath.join(tmpdir(), \"slice-machine-infer-slice-tmp-\"),\n\t\t\t\t);\n\t\t\t\tconst tmpImagePath = path.join(tmpDir, `${randomUUID()}.png`);\n\t\t\t\tconst response = await fetch(imageUrl);\n\t\t\t\tif (!response.ok) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Failed to download image: ${response.status} ${response.statusText}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tawait writeFile(\n\t\t\t\t\ttmpImagePath,\n\t\t\t\t\tBuffer.from(await response.arrayBuffer()),\n\t\t\t\t);\n\n\t\t\t\tconst queries = queryClaude({\n\t\t\t\t\tprompt: `CRITICAL INSTRUCTIONS - READ FIRST:\n- You MUST start immediately with Step 1.1. DO NOT read, analyze, or explore any project files first.\n- Work step-by-step through the numbered tasks below.\n- DO NOT present any summary, explanation, or completion message after finishing.\n- DO NOT create TODO lists while performing tasks.\n- Keep responses minimal - only show necessary tool calls and brief progress notes.\n\n# CONTEXT \n\nThe user wants to build a new Prismic Slice based on a design image they provided.\nYour goal is to analyze the design image and generate the JSON model data and boilerplate code for the slice following Prismic requirements.\n\nYou will work under the slice library at <slice_library_path>, where all the slices are stored.\n\n# AVAILABLE RESOURCES\n\n<design_image_path>\n${tmpImagePath}\n</design_image_path>\n\n<slice_library_path>\n${libraryAbsPath}\n</slice_library_path>\n\n<framework>\n${framework.label}\n</framework>\n\n# AVAILABLE TOOLS\n\nYou have access to specialized Prismic MCP tools for this task:\n\n<tool name=\"mcp__prismic__how_to_model_slice\">\n<description>\nProvides detailed guidance on creating Prismic slice models, including field types, naming conventions, and best practices.\n</description>\n<when_to_use>\nCall this tool in Step 2.1 to learn how to structure the slice model data for the design you analysed.\n</when_to_use>\n</tool>\n\n<tool name=\"mcp__prismic__how_to_code_slice\">\n<description>\nProvides guidance on implementing Prismic slice components, including how to use Prismic field components, props structure, and best practices.\n</description>\n<when_to_use>\nCall this tool in Step 2.1 to learn how to properly structure the slice component with Prismic fields.\n</when_to_use>\n</tool>\n\n<tool name=\"mcp__prismic__save_slice_data\">\n<description>\nValidates and saves the slice model data to model.json. This is the ONLY way to create the model file.\n</description>\n<when_to_use>\nCall this tool in Step 2.3 after you have built the complete slice model structure in memory.\n</when_to_use>\n</tool>\n\n# TASK REQUIREMENTS\n\n## Step 1: Gather information from the design image\n1.1. Analyse the design image at <design_image_path>.\n1.2. Identify all elements in the image that should be dynamically editable (e.g., headings, paragraphs, images, links, buttons, etc.).\n1.3. List the slice directories under <slice_library_path>.\n1.4. Come up with a unique name for the new slice based on the content of the image and the slice directories.\n\n## Step 2: Model the Prismic slice\n2.1. Call mcp__prismic__how_to_model_slice to learn how to structure the model for this design.\n- Make sure the name you use for the new slice does not yet exist in the slice library at <slice_library_path>. If it does, use a different name.\n2.2. Build the complete slice JSON model data in memory based on the guidance received and the information extracted from the image.\n2.3. Call mcp__prismic__save_slice_data to save the model (DO NOT manually write model.json) in the slice library at <slice_library_path>.\n\n## Step 3: Code a boilerplate slice component based on the model\n3.1. Call mcp__prismic__how_to_code_slice to learn how to properly structure the slice component with Prismic fields.\n3.2. Update the slice component code at <slice_library_path>/index.${frameworkFileExtension}, replacing the placeholder code with boilerplate code with the following requirements:\n- Must NOT be based on existing slices or components from the codebase.\n- Must render all the Prismic components to display the fields of the slice model created at <slice_model_path>.\n- Must be a valid ${framework.label} component.\n- Must NOT have any styling/CSS. No inlines styles or classNames. Just the skeleton component structure.\n- Must NOT use any other custom component or functions from the user's codebase.\n- Avoid creating unnecessary wrapper elements, like if they only wrap a single component (e.g., <div><PrismicRichText /></div>).\n\n## Step 4: Present the newly created slice path\n4.1. Present the path to the newly created slice in the following format: <new_slice_path>${libraryAbsPath}/MyNewSlice</new_slice_path>.\n- \"MyNewSlice\" must be the name of the directory of the newly created slice.\n\n# EXAMPLE OF CORRECT EXECUTION\n\n<example>\nAssistant: Step 1.1: Analysing design image...\n[reads <design_image_path>]\n\nStep 1.2: Identifying editable content elements...\n[identifies: title field, description field, buttonText field, buttonLink field, backgroundImage field]\n\nStep 1.3: Listing slice directories under <slice_library_path>...\n[lists slice directories: Hero, Hero2, Hero3]\n\nStep 1.4: Coming up with a unique name for the new slice...\n[comes up with a unique name for the new slice: Hero4]\n\nStep 2.1: Getting Prismic modeling guidance...\n[calls mcp__prismic__how_to_model_slice]\n\nStep 2.2: Building slice model based on guidance and the information extracted...\n[creates model with title field, description field, buttonText field, buttonLink field, backgroundImage field]\n\nStep 2.3: Saving slice model...\n[calls mcp__prismic__save_slice_data]\n\nStep 3.1: Learning Prismic slice coding requirements...\n[calls mcp__prismic__how_to_code_slice]\n\nStep 3.2: Coding boilerplate slice component based on the model...\n[updates component with Prismic field components, no styling, no other components]\n\nStep 4.1: Presenting the path to the newly created slice...\n[presents <new_slice_path>${path.join(\n\t\t\t\t\t\tlibraryAbsPath,\n\t\t\t\t\t\t\"MyNewSlice\",\n\t\t\t\t\t)}</new_slice_path>]\n\n# DELIVERABLES\n- Slice model saved to <slice_library_path>/model.json using mcp__prismic__save_slice_data\n- Slice component at <slice_library_path>/index.${frameworkFileExtension} updated with boilerplate code\n- New slice path presented in the format mentioned in Step 3.1\n\nYOU ARE NOT FINISHED UNTIL YOU HAVE THESE DELIVERABLES.\n\n---\n\nFINAL REMINDERS:\n- You MUST use mcp__prismic__save_slice_data to save the model\n- You MUST call mcp__prismic__how_to_code_slice in Step 3.1\n- DO NOT ATTEMPT TO BUILD THE APPLICATION\n- START IMMEDIATELY WITH STEP 1.1 - NO PRELIMINARY ANALYSIS;`,\n\t\t\t\t\toptions: {\n\t\t\t\t\t\tcwd: libraryAbsPath,\n\t\t\t\t\t\tstderr: (data) => console.error(data),\n\t\t\t\t\t\tmodel: \"claude-haiku-4-5\",\n\t\t\t\t\t\tpermissionMode: \"bypassPermissions\",\n\t\t\t\t\t\tallowedTools: [\n\t\t\t\t\t\t\t\"Bash\",\n\t\t\t\t\t\t\t\"Read\",\n\t\t\t\t\t\t\t\"FileSearch\",\n\t\t\t\t\t\t\t\"Grep\",\n\t\t\t\t\t\t\t\"Glob\",\n\t\t\t\t\t\t\t\"Task\",\n\t\t\t\t\t\t\t\"Edit\",\n\t\t\t\t\t\t\t\"Write\",\n\t\t\t\t\t\t\t\"MultiEdit\",\n\t\t\t\t\t\t\t\"mcp__prismic__how_to_model_slice\",\n\t\t\t\t\t\t\t\"mcp__prismic__how_to_code_slice\",\n\t\t\t\t\t\t\t\"mcp__prismic__save_slice_data\",\n\t\t\t\t\t\t],\n\t\t\t\t\t\tdisallowedTools: [\n\t\t\t\t\t\t\t`Edit(**/model.json)`,\n\t\t\t\t\t\t\t`Write(**/model.json)`,\n\t\t\t\t\t\t\t\"Edit(**/mocks.json)\",\n\t\t\t\t\t\t\t\"Write(**/mocks.json)\",\n\t\t\t\t\t\t],\n\t\t\t\t\t\tenv: {\n\t\t\t\t\t\t\t...process.env,\n\t\t\t\t\t\t\tANTHROPIC_BASE_URL: llmProxyUrl,\n\t\t\t\t\t\t\tANTHROPIC_CUSTOM_HEADERS:\n\t\t\t\t\t\t\t\t`x-prismic-token: ${authToken}\\n` +\n\t\t\t\t\t\t\t\t`x-prismic-repository: ${repository}\\n`,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tmcpServers: {\n\t\t\t\t\t\t\tprismic: {\n\t\t\t\t\t\t\t\ttype: \"stdio\",\n\t\t\t\t\t\t\t\tcommand: \"npx\",\n\t\t\t\t\t\t\t\targs: [\"-y\", \"@prismicio/mcp-server@0.0.20-alpha.6\"],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t});\n\n\t\t\t\tlet newSliceAbsPath: string | undefined;\n\n\t\t\t\tfor await (const query of queries) {\n\t\t\t\t\tswitch (query.type) {\n\t\t\t\t\t\tcase \"result\":\n\t\t\t\t\t\t\tif (query.subtype === \"success\") {\n\t\t\t\t\t\t\t\tnewSliceAbsPath = query.result.match(\n\t\t\t\t\t\t\t\t\t/<new_slice_path>(.*)<\\/new_slice_path>/s,\n\t\t\t\t\t\t\t\t)?.[1];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (!newSliceAbsPath) {\n\t\t\t\t\tthrow new Error(\"Could not find path for the newly created slice.\");\n\t\t\t\t}\n\n\t\t\t\tconst model = await readFile(\n\t\t\t\t\tpath.join(newSliceAbsPath, \"model.json\"),\n\t\t\t\t\t\"utf8\",\n\t\t\t\t);\n\n\t\t\t\tif (!model) {\n\t\t\t\t\tthrow new Error(\"Could not find model for the newly created slice.\");\n\t\t\t\t}\n\n\t\t\t\t// move the screenshot image to the new slice directory\n\t\t\t\tawait rename(\n\t\t\t\t\ttmpImagePath,\n\t\t\t\t\tpath.join(newSliceAbsPath, \"screenshot-default.png\"),\n\t\t\t\t);\n\t\t\t\tawait rm(tmpDir, { recursive: true });\n\n\t\t\t\tconst elapsedTimeSeconds = (Date.now() - startTime) / 1000;\n\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\tconsole.log(`inferSlice took ${elapsedTimeSeconds}s`);\n\n\t\t\t\treturn InferSliceResponse.parse({ slice: JSON.parse(model) });\n\t\t\t} catch (error) {\n\t\t\t\tif (tmpDir && existsSync(tmpDir)) {\n\t\t\t\t\tawait rm(tmpDir, { recursive: true });\n\t\t\t\t}\n\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t} else {\n\t\t\tconst headers = {\n\t\t\t\tAuthorization: `Bearer ${authToken}`,\n\t\t\t};\n\n\t\t\tconst searchParams = new URLSearchParams({\n\t\t\t\trepository,\n\t\t\t});\n\n\t\t\tconst url = new URL(\"./slices/infer\", API_ENDPOINTS.CustomTypeService);\n\t\t\turl.search = searchParams.toString();\n\n\t\t\tconst response = await fetch(url.toString(), {\n\t\t\t\tmethod: \"POST\",\n\t\t\t\theaders: headers,\n\t\t\t\tbody: JSON.stringify({ imageUrl }),\n\t\t\t});\n\n\t\t\tif (!response.ok) {\n\t\t\t\tthrow new Error(`Failed to infer slice: ${response.statusText}`);\n\t\t\t}\n\n\t\t\tconst json = await response.json();\n\n\t\t\treturn InferSliceResponse.parse(json);\n\t\t}\n\t}\n}\n\ntype InferSliceResponse = z.infer<typeof InferSliceResponse>;\n\nconst InferSliceResponse = z.object({\n\tslice: z.custom().transform((value, ctx) => {\n\t\tconst result = SharedSlice.decode(value);\n\t\tif (result._tag === \"Right\") {\n\t\t\treturn result.right;\n\t\t}\n\t\tctx.addIssue({\n\t\t\tcode: z.ZodIssueCode.custom,\n\t\t\tmessage: `Invalid shared slice: ${JSON.stringify(value, null, 2)}`,\n\t\t});\n\n\t\treturn z.NEVER;\n\t}),\n\tlangSmithUrl: z.string().url().optional(),\n});\n\nfunction updateCRCustomType(\n\targs: { customType: LinkCustomType } & CustomTypeFieldIdChangedMeta,\n): LinkCustomType {\n\tconst previousPath = getPathIds(args.previousPath);\n\tconst newPath = getPathIds(args.newPath);\n\n\tif (!previousPath.customTypeId || !newPath.customTypeId) {\n\t\tthrow new Error(\n\t\t\t`Could not find a customtype id in previousPath (${args.previousPath.join(\n\t\t\t\t\".\",\n\t\t\t)}) and/or newPath (${args.newPath.join(\n\t\t\t\t\".\",\n\t\t\t)}), which should not be possible.`,\n\t\t);\n\t}\n\n\tif (!previousPath.fieldId || !newPath.fieldId) {\n\t\tthrow new Error(\n\t\t\t`Could not find a field id in previousPath (${args.previousPath.join(\n\t\t\t\t\".\",\n\t\t\t)}) and/or newPath (${args.newPath.join(\n\t\t\t\t\".\",\n\t\t\t)}), which should not be possible.`,\n\t\t);\n\t}\n\n\tconst customType = shallowCloneIfObject(args.customType);\n\n\tif (typeof customType === \"string\") {\n\t\t// Legacy format support, we don't have anything to update here.\n\t\treturn customType;\n\t}\n\n\tconst matchedCustomTypeId = customType.id === previousPath.customTypeId;\n\n\treturn {\n\t\t...customType,\n\t\tfields: customType.fields.map((fieldArg) => {\n\t\t\tconst customTypeField = shallowCloneIfObject(fieldArg);\n\n\t\t\t// Regular field\n\t\t\tif (typeof customTypeField === \"string\") {\n\t\t\t\tif (\n\t\t\t\t\tmatchedCustomTypeId &&\n\t\t\t\t\tcustomTypeField === previousPath.fieldId &&\n\t\t\t\t\tcustomTypeField !== newPath.fieldId\n\t\t\t\t) {\n\t\t\t\t\t// The id of the field has changed.\n\t\t\t\t\treturn newPath.fieldId;\n\t\t\t\t}\n\n\t\t\t\treturn customTypeField;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tmatchedCustomTypeId &&\n\t\t\t\tcustomTypeField.id === previousPath.fieldId &&\n\t\t\t\tcustomTypeField.id !== newPath.fieldId\n\t\t\t) {\n\t\t\t\t// The id of the field has changed. We don't exit return because there\n\t\t\t\t// might be other fields further down in nested custom types or groups\n\t\t\t\t// that need to be updated.\n\t\t\t\tcustomTypeField.id = newPath.fieldId;\n\t\t\t}\n\n\t\t\t// Group field\n\t\t\tif (\"fields\" in customTypeField) {\n\t\t\t\tif (\n\t\t\t\t\t!previousPath.groupId &&\n\t\t\t\t\t!newPath.groupId &&\n\t\t\t\t\tcustomTypeField.id === previousPath.fieldId &&\n\t\t\t\t\tcustomTypeField.id !== newPath.fieldId\n\t\t\t\t) {\n\t\t\t\t\t// Only the id of the group has changed. Group id is not defined, so\n\t\t\t\t\t// we can return early.\n\t\t\t\t\treturn newPath.fieldId;\n\t\t\t\t}\n\n\t\t\t\tconst matchedGroupId = customTypeField.id === previousPath.groupId;\n\n\t\t\t\tif (\n\t\t\t\t\tpreviousPath.groupId &&\n\t\t\t\t\tnewPath.groupId &&\n\t\t\t\t\tmatchedGroupId &&\n\t\t\t\t\tcustomTypeField.id !== newPath.groupId\n\t\t\t\t) {\n\t\t\t\t\t// The id of the group field has changed, so we update it. We don't\n\t\t\t\t\t// return because there are group fields that may need to be updated.\n\t\t\t\t\tcustomTypeField.id = newPath.groupId;\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\t...customTypeField,\n\t\t\t\t\tfields: customTypeField.fields.map((groupFieldArg) => {\n\t\t\t\t\t\tconst groupField = shallowCloneIfObject(groupFieldArg);\n\n\t\t\t\t\t\t// Regular field inside a group field\n\t\t\t\t\t\tif (typeof groupField === \"string\") {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tmatchedGroupId &&\n\t\t\t\t\t\t\t\tgroupField === previousPath.fieldId &&\n\t\t\t\t\t\t\t\tgroupField !== newPath.fieldId\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t// The id of the field inside the group has changed.\n\t\t\t\t\t\t\t\treturn newPath.fieldId;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\treturn groupField;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Content relationship field inside a group field\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...groupField,\n\t\t\t\t\t\t\tfields: updateContentRelationshipFields({\n\t\t\t\t\t\t\t\tcustomtypes: groupField.customtypes,\n\t\t\t\t\t\t\t\tpreviousPath,\n\t\t\t\t\t\t\t\tnewPath,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t};\n\t\t\t\t\t}),\n\t\t\t\t};\n\t\t\t}\n\n\t\t\t// Content relationship field\n\t\t\treturn {\n\t\t\t\t...customTypeField,\n\t\t\t\tcustomtypes: updateContentRelationshipFields({\n\t\t\t\t\tcustomtypes: customTypeField.customtypes,\n\t\t\t\t\tpreviousPath,\n\t\t\t\t\tnewPath,\n\t\t\t\t}),\n\t\t\t};\n\t\t}),\n\t};\n}\n\nfunction updateContentRelationshipFields(args: {\n\tcustomtypes: readonly (\n\t\t| string\n\t\t| {\n\t\t\t\tid: string;\n\t\t\t\tfields: readonly (string | { id: string; fields: readonly string[] })[];\n\t\t }\n\t)[];\n\tpreviousPath: CrUpdatePathIds;\n\tnewPath: CrUpdatePathIds;\n}) {\n\tconst { customtypes, previousPath, newPath } = args;\n\n\treturn customtypes.map((nestedCtArg) => {\n\t\tconst nestedCt = shallowCloneIfObject(nestedCtArg);\n\n\t\tif (\n\t\t\ttypeof nestedCt === \"string\" ||\n\t\t\t// Since we are entering a new custom type, if the previous id\n\t\t\t// doesn't match, we can return early, because it's not the\n\t\t\t// custom type we are looking for.\n\t\t\tnestedCt.id !== previousPath.customTypeId\n\t\t) {\n\t\t\treturn nestedCt;\n\t\t}\n\n\t\treturn {\n\t\t\t...nestedCt,\n\t\t\tfields: nestedCt.fields.map((nestedCtFieldArg) => {\n\t\t\t\tconst nestedCtField = shallowCloneIfObject(nestedCtFieldArg);\n\n\t\t\t\t// Regular field\n\t\t\t\tif (typeof nestedCtField === \"string\") {\n\t\t\t\t\tif (\n\t\t\t\t\t\tnestedCtField === previousPath.fieldId &&\n\t\t\t\t\t\tnestedCtField !== newPath.fieldId\n\t\t\t\t\t) {\n\t\t\t\t\t\t// The id of the field has changed.\n\t\t\t\t\t\treturn newPath.fieldId;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn nestedCtField;\n\t\t\t\t}\n\n\t\t\t\t// Group field\n\n\t\t\t\tif (\n\t\t\t\t\tnestedCtField.id === previousPath.fieldId &&\n\t\t\t\t\tnestedCtField.id !== newPath.fieldId\n\t\t\t\t) {\n\t\t\t\t\t// The id of the field has changed.\n\t\t\t\t\tnestedCtField.id = newPath.fieldId;\n\t\t\t\t}\n\n\t\t\t\t// Further down the path, the field can only be a group field. So if we have\n\t\t\t\t// no group id defined, no need to continue.\n\t\t\t\tif (\n\t\t\t\t\t!previousPath.groupId ||\n\t\t\t\t\t!newPath.groupId ||\n\t\t\t\t\tnestedCtField.id !== previousPath.groupId\n\t\t\t\t) {\n\t\t\t\t\treturn nestedCtField;\n\t\t\t\t}\n\n\t\t\t\tif (nestedCtField.id !== newPath.groupId) {\n\t\t\t\t\t// The id of the group has changed.\n\t\t\t\t\tnestedCtField.id = newPath.groupId;\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\t...nestedCtField,\n\t\t\t\t\tfields: nestedCtField.fields.map((nestedCtGroupFieldId) => {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tnestedCtGroupFieldId === previousPath.fieldId &&\n\t\t\t\t\t\t\tnestedCtGroupFieldId !== newPath.fieldId\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t// The id of the field inside the group has changed.\n\t\t\t\t\t\t\treturn newPath.fieldId;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn nestedCtGroupFieldId;\n\t\t\t\t\t}),\n\t\t\t\t};\n\t\t\t}),\n\t\t};\n\t});\n}\n\n/**\n * Update the Content Relationship API IDs of a single field. The change is\n * determined by the `previousPath` and `newPath` properties.\n */\nfunction updateFieldContentRelationships<\n\tT extends UID | NestableWidget | Group | NestedGroup,\n>(args: { field: T } & CustomTypeFieldIdChangedMeta): T {\n\tconst { field, ...updateMeta } = args;\n\tif (\n\t\tfield.type !== \"Link\" ||\n\t\tfield.config?.select !== \"document\" ||\n\t\t!field.config?.customtypes\n\t) {\n\t\t// not a content relationship field\n\t\treturn field;\n\t}\n\n\tconst newCustomTypes = field.config.customtypes.map((customType) => {\n\t\treturn updateCRCustomType({ ...updateMeta, customType });\n\t});\n\n\treturn {\n\t\t...field,\n\t\tconfig: { ...field.config, customtypes: newCustomTypes },\n\t};\n}\n\nexport function updateCustomTypeContentRelationships(\n\targs: {\n\t\tmodels: { model: CustomType }[];\n\t\tonUpdate: (model: { previousModel: CustomType; model: CustomType }) => void;\n\t} & CustomTypeFieldIdChangedMeta,\n): void {\n\tconst { models, previousPath, newPath, onUpdate } = args;\n\n\tfor (const { model: customType } of models) {\n\t\tconst updatedCustomType = traverseCustomType({\n\t\t\tcustomType,\n\t\t\tonField: ({ field }) => {\n\t\t\t\treturn updateFieldContentRelationships({\n\t\t\t\t\tfield,\n\t\t\t\t\tpreviousPath,\n\t\t\t\t\tnewPath,\n\t\t\t\t});\n\t\t\t},\n\t\t});\n\n\t\tif (!isEqualModel(customType, updatedCustomType)) {\n\t\t\tonUpdate({ model: updatedCustomType, previousModel: customType });\n\t\t}\n\t}\n}\n\nexport function updateSharedSliceContentRelationships(\n\targs: {\n\t\tmodels: { model: SharedSlice }[];\n\t\tonUpdate: (model: {\n\t\t\tpreviousModel: SharedSlice;\n\t\t\tmodel: SharedSlice;\n\t\t}) => void;\n\t} & CustomTypeFieldIdChangedMeta,\n): void {\n\tconst { models, previousPath, newPath, onUpdate } = args;\n\n\tfor (const { model: slice } of models) {\n\t\tconst updateSlice = traverseSharedSlice({\n\t\t\tpath: [],\n\t\t\tslice,\n\t\t\tonField: ({ field }) => {\n\t\t\t\treturn updateFieldContentRelationships({\n\t\t\t\t\tfield,\n\t\t\t\t\tpreviousPath,\n\t\t\t\t\tnewPath,\n\t\t\t\t});\n\t\t\t},\n\t\t});\n\n\t\tif (!isEqualModel(slice, updateSlice)) {\n\t\t\tonUpdate({ model: updateSlice, previousModel: slice });\n\t\t}\n\t}\n}\n\ninterface CrUpdatePathIds {\n\tcustomTypeId: string;\n\tgroupId: string | undefined;\n\tfieldId: string;\n}\n\nfunction getPathIds(path: PathWithCustomType): CrUpdatePathIds {\n\tif (path.length < 2) {\n\t\tthrow new Error(\n\t\t\t`Unexpected path length ${\n\t\t\t\tpath.length\n\t\t\t}. Expected at least 2 segments (got: ${path.join(\".\")}).`,\n\t\t);\n\t}\n\n\tconst [customTypeId, groupOrFieldId, fieldId] = path;\n\n\treturn {\n\t\tcustomTypeId,\n\t\t/**\n\t\t * Id of a changed group. If it's defined, it means that a group or a field\n\t\t * inside a group had its API ID renamed. It's defined when the path has a\n\t\t * third element (e.g. `[\"customtypeA\", \"groupA\", \"fieldA\"]`).\n\t\t */\n\t\tgroupId: fieldId ? groupOrFieldId : undefined,\n\t\tfieldId: fieldId || groupOrFieldId,\n\t};\n}\n\nfunction isEqualModel<T extends CustomType | SharedSlice>(\n\tmodelA: T,\n\tmodelB: T,\n): boolean {\n\treturn JSON.stringify(modelA) === JSON.stringify(modelB);\n}\n\nfunction shallowCloneIfObject<T>(value: T): T {\n\tif (typeof value === \"object\") {\n\t\treturn { ...value };\n\t}\n\n\treturn value;\n}\n"],"names":["errors","_a","queryClaude","query","path"],"mappings":";;;;;;;;;;;;;;;;;AAuIM,MAAO,2BAA2B,YAAW;AAAA,EAClD,MAAM,wBAAqB;;AAC1B,6BAAyB,KAAK,wBAAwB;AAEtD,UAAM,aAAa,MAAM,KAAK,yBAAyB,SACtD,4BACA,MAAS;AAEV,UAAM,EAAE,MAAM,OAAA,IAAW,iBACxB,EAAE,KAAK;AAAA,MACN,KAAK,EAAE,MAAM,EAAE,MAAM;AAAA,IAAA,CACrB,GACD,UAAU;AAGX,WAAO;AAAA,MACN,OAAK,UAAK,CAAC,MAAN,mBAAS,QAAO,CAAA;AAAA,MACrB;AAAA,IAAA;AAA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;AAAA,EACb;AAEA,SAAO;AACR;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slicemachine/manager",
3
- "version": "0.25.7-alpha.jp-figma-to-prismic.4",
3
+ "version": "0.25.7-alpha.jp-figma-to-prismic.6",
4
4
  "description": "Manage all aspects of a Slice Machine project.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -71,7 +71,7 @@
71
71
  "@prismicio/mocks": "2.14.0",
72
72
  "@prismicio/types-internal": "3.11.2",
73
73
  "@segment/analytics-node": "^2.1.2",
74
- "@slicemachine/plugin-kit": "0.4.85-alpha.jp-figma-to-prismic.4",
74
+ "@slicemachine/plugin-kit": "0.4.85-alpha.jp-figma-to-prismic.6",
75
75
  "cookie": "^1.0.1",
76
76
  "cors": "^2.8.5",
77
77
  "execa": "^7.1.1",
@@ -13,7 +13,6 @@ export type APIEndpoints = {
13
13
  RepositoryService: string;
14
14
  LocaleService: string;
15
15
  CustomTypeService: string;
16
- LlmProxyTypeService: string;
17
16
  };
18
17
 
19
18
  export const API_ENDPOINTS: APIEndpoints = (() => {
@@ -48,10 +47,6 @@ export const API_ENDPOINTS: APIEndpoints = (() => {
48
47
  process.env.custom_type_api ??
49
48
  "https://api.internal.wroom.io/custom-type/",
50
49
  ),
51
- LlmProxyTypeService: addTrailingSlash(
52
- process.env.llm_proxy_api ??
53
- "https://sbqznqszdlqhjn4p4nfhtst6ra0wngjc.lambda-url.us-east-1.on.aws/",
54
- ),
55
50
  };
56
51
 
57
52
  const missingAPIEndpoints = Object.keys(apiEndpoints).filter((key) => {
@@ -101,8 +96,6 @@ If you didn't intend to run Slice Machine this way, stop it immediately and unse
101
96
  RepositoryService: "https://api.internal.wroom.io/repository/",
102
97
  LocaleService: "https://api.internal.wroom.io/locale/",
103
98
  CustomTypeService: "https://api.internal.wroom.io/custom-type/",
104
- LlmProxyTypeService:
105
- "https://sbqznqszdlqhjn4p4nfhtst6ra0wngjc.lambda-url.us-east-1.on.aws/",
106
99
  };
107
100
  }
108
101
 
@@ -121,8 +114,6 @@ If you didn't intend to run Slice Machine this way, stop it immediately and unse
121
114
  RepositoryService: `https://api.internal.${process.env.SM_ENV}-wroom.com/repository/`,
122
115
  LocaleService: `https://api.internal.${process.env.SM_ENV}-wroom.com/locale/`,
123
116
  CustomTypeService: `https://api.internal.${process.env.SM_ENV}-wroom.com/custom-type/`,
124
- LlmProxyTypeService:
125
- "https://sbqznqszdlqhjn4p4nfhtst6ra0wngjc.lambda-url.us-east-1.on.aws/",
126
117
  };
127
118
  }
128
119
 
@@ -140,8 +131,6 @@ If you didn't intend to run Slice Machine this way, stop it immediately and unse
140
131
  RepositoryService: "https://api.internal.prismic.io/repository/",
141
132
  LocaleService: "https://api.internal.prismic.io/locale/",
142
133
  CustomTypeService: "https://api.internal.prismic.io/custom-type/",
143
- LlmProxyTypeService:
144
- "https://sbqznqszdlqhjn4p4nfhtst6ra0wngjc.lambda-url.us-east-1.on.aws/",
145
134
  };
146
135
  }
147
136
  }
@@ -546,6 +546,15 @@ export class CustomTypesManager extends BaseManager {
546
546
  ),
547
547
  ): Promise<InferSliceResponse> {
548
548
  const { source, imageUrl } = args;
549
+
550
+ const exp = await this.telemetry.getExperimentVariant("llm-proxy-access");
551
+ if (exp?.value !== "on") {
552
+ throw new Error("LLM proxy access is not enabled.");
553
+ }
554
+ const { llmProxyUrl } = z
555
+ .object({ llmProxyUrl: z.string() })
556
+ .parse(exp.payload);
557
+
549
558
  const authToken = await this.user.getAuthenticationToken();
550
559
  const repository = await this.project.getResolvedRepositoryName();
551
560
 
@@ -777,7 +786,7 @@ FINAL REMINDERS:
777
786
  ],
778
787
  env: {
779
788
  ...process.env,
780
- ANTHROPIC_BASE_URL: API_ENDPOINTS.LlmProxyTypeService,
789
+ ANTHROPIC_BASE_URL: llmProxyUrl,
781
790
  ANTHROPIC_CUSTOM_HEADERS:
782
791
  `x-prismic-token: ${authToken}\n` +
783
792
  `x-prismic-repository: ${repository}\n`,