@alpic-ai/sdk 0.0.0-staging.ge1f4e64 → 0.0.0-staging.ge3be0ba

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,4 +1,5 @@
1
1
  import { existsSync, readFileSync } from "node:fs";
2
+ import { detectPythonRuntimeFromRequirement } from "./python-runtime.js";
2
3
  export function detectRuntime() {
3
4
  const has = (file) => existsSync(file);
4
5
  const read = (file) => {
@@ -10,15 +11,32 @@ export function detectRuntime() {
10
11
  }
11
12
  };
12
13
  if (has("pyproject.toml") || has("requirements.txt") || has("setup.py") || has(".python-version")) {
14
+ const version = has(".python-version")
15
+ ? read(".python-version")
16
+ .trim()
17
+ .match(/^3\.(\d+)/)?.[1]
18
+ : undefined;
19
+ if (version) {
20
+ return Number(version) >= 15 ? "python3.15" : "python3.13";
21
+ }
22
+ const requiresPython = has("pyproject.toml")
23
+ ? read("pyproject.toml").match(/requires-python\s*=\s*["']([^"']+)["']/)?.[1]
24
+ : undefined;
25
+ if (requiresPython) {
26
+ const runtime = detectPythonRuntimeFromRequirement(requiresPython);
27
+ if (runtime !== undefined) {
28
+ return runtime;
29
+ }
30
+ }
13
31
  return "python3.13";
14
32
  }
15
33
  if (has("package.json")) {
16
34
  const nvmrc = has(".nvmrc") ? (read(".nvmrc").trim().split(/\s/)[0] ?? "") : "";
17
35
  const major = nvmrc.replace(/^v/i, "").match(/^(\d+)/)?.[1];
18
- if (major === "22") {
19
- return "node22";
36
+ if (major === "22" || major === "24") {
37
+ return `node${major}`;
20
38
  }
21
- return "node24";
39
+ return "node26";
22
40
  }
23
41
  return null;
24
42
  }
@@ -1 +1 @@
1
- {"version":3,"file":"detect-runtime.js","sourceRoot":"","sources":["../../src/project/detect-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAGnD,MAAM,UAAU,aAAa;IAC3B,MAAM,GAAG,GAAG,CAAC,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AAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAChF,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QAC5D,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YACrC,OAAO,OAAO,KAAK,EAAE,CAAC;QACxB,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1 @@
1
+ export declare function detectPythonRuntimeFromRequirement(requiresPython: string): "python3.13" | "python3.14" | "python3.15" | null | undefined;
@@ -0,0 +1,71 @@
1
+ export function detectPythonRuntimeFromRequirement(requiresPython) {
2
+ const constraints = requiresPython.split(",").map((specifier) => {
3
+ const match = specifier
4
+ .trim()
5
+ .match(/^(>=|<=|~=|===|==|!=|>|<)?\s*(\d+)(?:\.(\d+))?(?:\.(\d+))?((?:a|b|rc)\d*(?:\.dev\d*)?|\.dev\d*)?(\.\*)?$/i);
6
+ if (!match ||
7
+ (match[6] && (match[5] || !["==", "!=", undefined].includes(match[1]))) ||
8
+ (match[1] === "~=" && !match[3])) {
9
+ return null;
10
+ }
11
+ return {
12
+ operator: match[1] ?? "==",
13
+ major: Number(match[2]),
14
+ minor: Number(match[3] ?? 0),
15
+ patch: Number(match[4] ?? 0),
16
+ hasMinor: match[3] !== undefined,
17
+ hasPatch: match[4] !== undefined,
18
+ prerelease: match[5] !== undefined,
19
+ wildcard: match[6] !== undefined,
20
+ };
21
+ });
22
+ if (constraints.some((constraint) => constraint === null)) {
23
+ return undefined;
24
+ }
25
+ const parsed = constraints.filter((constraint) => constraint !== null);
26
+ const lowerBounds = parsed
27
+ .filter(({ operator, major }) => major === 3 && !["<", "<=", "!="].includes(operator))
28
+ .map(({ minor }) => minor);
29
+ const preferredMinor = Math.max(...(lowerBounds.length ? lowerBounds : [14]));
30
+ const supportedRuntimes = ["python3.13", "python3.14", "python3.15"].map((runtime) => ({
31
+ runtime,
32
+ minor: Number(runtime.split(".")[1]),
33
+ }));
34
+ const candidates = [
35
+ ...supportedRuntimes.filter(({ minor }) => minor === preferredMinor),
36
+ ...supportedRuntimes.filter(({ minor }) => minor !== preferredMinor),
37
+ ];
38
+ const patches = [0, ...parsed.flatMap(({ patch }) => [patch, patch + 1])];
39
+ const runtime = candidates.find(({ minor }) => patches.some((patch) => parsed.every((constraint) => {
40
+ const comparison = 3 - constraint.major ||
41
+ minor - constraint.minor ||
42
+ patch - constraint.patch ||
43
+ (constraint.prerelease ? 1 : 0);
44
+ const matches = constraint.wildcard
45
+ ? constraint.major === 3 &&
46
+ (!constraint.hasMinor || minor === constraint.minor) &&
47
+ (!constraint.hasPatch || patch === constraint.patch)
48
+ : comparison === 0;
49
+ switch (constraint.operator) {
50
+ case "==":
51
+ case "===":
52
+ return matches;
53
+ case "!=":
54
+ return !matches;
55
+ case ">=":
56
+ return comparison >= 0;
57
+ case ">":
58
+ return comparison > 0;
59
+ case "<=":
60
+ return comparison <= 0;
61
+ case "<":
62
+ return comparison < 0;
63
+ case "~=":
64
+ return comparison >= 0 && constraint.major === 3 && (!constraint.hasPatch || minor === constraint.minor);
65
+ default:
66
+ return false;
67
+ }
68
+ })));
69
+ return runtime?.runtime ?? null;
70
+ }
71
+ //# sourceMappingURL=python-runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"python-runtime.js","sourceRoot":"","sources":["../../src/project/python-runtime.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,kCAAkC,CAAC,cAAsB;IACvE,MAAM,WAAW,GAAG,cAAc,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,SAA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IAAI,IAAI,CAAC;AAClC,CAAC"}
@@ -11538,9 +11538,9 @@ var require_dist = __commonJS({
11538
11538
  }
11539
11539
  });
11540
11540
 
11541
- // ../../node_modules/.pnpm/follow-redirects@1.16.0_debug@4.4.3_supports-color@8.1.1_/node_modules/follow-redirects/debug.js
11541
+ // ../../node_modules/.pnpm/follow-redirects@1.16.2_debug@4.4.3_supports-color@8.1.1_/node_modules/follow-redirects/debug.js
11542
11542
  var require_debug = __commonJS({
11543
- "../../node_modules/.pnpm/follow-redirects@1.16.0_debug@4.4.3_supports-color@8.1.1_/node_modules/follow-redirects/debug.js"(exports, module) {
11543
+ "../../node_modules/.pnpm/follow-redirects@1.16.2_debug@4.4.3_supports-color@8.1.1_/node_modules/follow-redirects/debug.js"(exports, module) {
11544
11544
  var debug3;
11545
11545
  module.exports = function() {
11546
11546
  if (!debug3) {
@@ -11558,9 +11558,9 @@ var require_debug = __commonJS({
11558
11558
  }
11559
11559
  });
11560
11560
 
11561
- // ../../node_modules/.pnpm/follow-redirects@1.16.0_debug@4.4.3_supports-color@8.1.1_/node_modules/follow-redirects/index.js
11561
+ // ../../node_modules/.pnpm/follow-redirects@1.16.2_debug@4.4.3_supports-color@8.1.1_/node_modules/follow-redirects/index.js
11562
11562
  var require_follow_redirects = __commonJS({
11563
- "../../node_modules/.pnpm/follow-redirects@1.16.0_debug@4.4.3_supports-color@8.1.1_/node_modules/follow-redirects/index.js"(exports, module) {
11563
+ "../../node_modules/.pnpm/follow-redirects@1.16.2_debug@4.4.3_supports-color@8.1.1_/node_modules/follow-redirects/index.js"(exports, module) {
11564
11564
  var url2 = __require("url");
11565
11565
  var URL2 = url2.URL;
11566
11566
  var http3 = __require("http");
@@ -11788,8 +11788,14 @@ var require_follow_redirects = __commonJS({
11788
11788
  RedirectableRequest.prototype._sanitizeOptions = function(options) {
11789
11789
  if (!options.headers) {
11790
11790
  options.headers = {};
11791
+ } else if (Array.isArray(options.headers)) {
11792
+ var headerList = options.headers;
11793
+ options.headers = {};
11794
+ for (var i = 0; i < headerList.length; i += 2) {
11795
+ options.headers[headerList[i]] = headerList[i + 1];
11796
+ }
11791
11797
  }
11792
- if (!isArray2(options.sensitiveHeaders)) {
11798
+ if (!Array.isArray(options.sensitiveHeaders)) {
11793
11799
  options.sensitiveHeaders = [];
11794
11800
  }
11795
11801
  if (options.host) {
@@ -12046,9 +12052,6 @@ var require_follow_redirects = __commonJS({
12046
12052
  var dot = subdomain.length - domain.length - 1;
12047
12053
  return dot > 0 && subdomain[dot] === "." && subdomain.endsWith(domain);
12048
12054
  }
12049
- function isArray2(value) {
12050
- return value instanceof Array;
12051
- }
12052
12055
  function isString2(value) {
12053
12056
  return typeof value === "string" || value instanceof String;
12054
12057
  }
@@ -12062,7 +12065,7 @@ var require_follow_redirects = __commonJS({
12062
12065
  return URL2 && value instanceof URL2;
12063
12066
  }
12064
12067
  function escapeRegex(regex) {
12065
- return regex.replace(/[\]\\/()*+?.$]/g, "\\$&");
12068
+ return regex.replace(/[[\]\\/()*+?.^$|]/g, "\\$&");
12066
12069
  }
12067
12070
  module.exports = wrap({ http: http3, https: https2 });
12068
12071
  module.exports.wrap = wrap;