casualos 3.4.1-alpha.14316240392 → 3.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/cli.js +56 -17
  2. package/package.json +4 -4
package/dist/cli.js CHANGED
@@ -98081,7 +98081,7 @@ var trace = TraceAPI.getInstance();
98081
98081
  function hashLowEntropyPasswordWithSalt2(password, salt) {
98082
98082
  const tracer = trace.getTracer(
98083
98083
  "InstrumentedHashHelpers",
98084
- false ? void 0 : "v3.4.1-alpha.14316240392"
98084
+ false ? void 0 : "v3.4.1"
98085
98085
  );
98086
98086
  return tracer.startActiveSpan(
98087
98087
  "hashLowEntropyPasswordWithSalt",
@@ -98099,7 +98099,7 @@ function hashLowEntropyPasswordWithSalt2(password, salt) {
98099
98099
  function hashHighEntropyPasswordWithSalt2(password, salt) {
98100
98100
  const tracer = trace.getTracer(
98101
98101
  "InstrumentedHashHelpers",
98102
- false ? void 0 : "v3.4.1-alpha.14316240392"
98102
+ false ? void 0 : "v3.4.1"
98103
98103
  );
98104
98104
  return tracer.startActiveSpan(
98105
98105
  "hashHighEntropyPasswordWithSalt",
@@ -98117,7 +98117,7 @@ function hashHighEntropyPasswordWithSalt2(password, salt) {
98117
98117
  function verifyPasswordAgainstHashes2(password, salt, hashes) {
98118
98118
  const tracer = trace.getTracer(
98119
98119
  "InstrumentedHashHelpers",
98120
- false ? void 0 : "v3.4.1-alpha.14316240392"
98120
+ false ? void 0 : "v3.4.1"
98121
98121
  );
98122
98122
  return tracer.startActiveSpan(
98123
98123
  "verifyPasswordAgainstHashes",
@@ -105069,7 +105069,7 @@ var import_semantic_conventions = __toESM(require_src3());
105069
105069
  function traced(tracerName, options = {}, metricOptions = {}) {
105070
105070
  const tracer = trace.getTracer(
105071
105071
  tracerName,
105072
- false ? void 0 : "v3.4.1-alpha.14316240392"
105072
+ false ? void 0 : "v3.4.1"
105073
105073
  );
105074
105074
  return function(target, propertyKey, descriptor) {
105075
105075
  const originalMethod = descriptor.value;
@@ -105147,7 +105147,7 @@ function getHistogram(meter) {
105147
105147
  }
105148
105148
  return metrics.getMeter(
105149
105149
  meter.meter,
105150
- false ? void 0 : "v3.4.1-alpha.14316240392"
105150
+ false ? void 0 : "v3.4.1"
105151
105151
  ).createHistogram(meter.name, meter.options);
105152
105152
  }
105153
105153
  function getCounter(meter) {
@@ -105156,7 +105156,7 @@ function getCounter(meter) {
105156
105156
  }
105157
105157
  return metrics.getMeter(
105158
105158
  meter.meter,
105159
- false ? void 0 : "v3.4.1-alpha.14316240392"
105159
+ false ? void 0 : "v3.4.1"
105160
105160
  ).createCounter(meter.name, meter.options);
105161
105161
  }
105162
105162
  function traceHttpResponse(options = {}) {
@@ -117263,7 +117263,7 @@ var RecordsServer = class {
117263
117263
  this._notificationsController = notificationsController;
117264
117264
  this._tracer = trace.getTracer(
117265
117265
  "RecordsServer",
117266
- false ? void 0 : "v3.4.1-alpha.14316240392"
117266
+ false ? void 0 : "v3.4.1"
117267
117267
  );
117268
117268
  this._procedures = this._createProcedures();
117269
117269
  this._setupRoutes();
@@ -119668,8 +119668,8 @@ var RecordsServer = class {
119668
119668
  return {
119669
119669
  success: true,
119670
119670
  ...metadata,
119671
- version: true ? "v3.4.1-alpha.14316240392" : void 0,
119672
- versionHash: true ? "7ae19d5c713490d6b6887939fa480e16be7111ae" : void 0
119671
+ version: true ? "v3.4.1" : void 0,
119672
+ versionHash: true ? "472297626e478e0883a9fc9eb544dc2a336b1afb" : void 0
119673
119673
  };
119674
119674
  })
119675
119675
  };
@@ -130023,16 +130023,32 @@ var SPAN_OPTIONS = {
130023
130023
  }
130024
130024
  };
130025
130025
  var OpenAIChatInterface = class {
130026
+ get _baseUrl() {
130027
+ return this._options.baseUrl ?? "https://api.openai.com/v1/";
130028
+ }
130029
+ get _name() {
130030
+ return this._options.name ?? "OpenAIChatInterface";
130031
+ }
130026
130032
  constructor(options) {
130027
130033
  this._options = options;
130028
130034
  this._client = new openai_default({
130029
- apiKey: options.apiKey
130035
+ apiKey: options.apiKey,
130036
+ baseURL: this._options.baseUrl ?? void 0
130030
130037
  });
130031
130038
  }
130032
130039
  async chat(request2) {
130033
130040
  try {
130041
+ if (this._options.name) {
130042
+ const span = trace.getActiveSpan();
130043
+ if (span) {
130044
+ span.setAttribute(
130045
+ "chat.interface.name",
130046
+ this._options.name
130047
+ );
130048
+ }
130049
+ }
130034
130050
  const result = await axios_default.post(
130035
- "https://api.openai.com/v1/chat/completions",
130051
+ `${this._baseUrl}chat/completions`,
130036
130052
  {
130037
130053
  model: request2.model,
130038
130054
  messages: request2.messages.map((m2) => ({
@@ -130070,10 +130086,10 @@ var OpenAIChatInterface = class {
130070
130086
  }
130071
130087
  );
130072
130088
  console.log(
130073
- `[OpenAIChatInterface] [${request2.userId}] [chat]: Total tokens: ${result.data.usage.total_tokens}`
130089
+ `[${this._name}] [${request2.userId}] [chat]: Total tokens: ${result.data.usage.total_tokens}`
130074
130090
  );
130075
130091
  console.log(
130076
- `[OpenAIChatInterface] [${request2.userId}] [chat]: Usage:`,
130092
+ `[${this._name}] [${request2.userId}] [chat]: Usage:`,
130077
130093
  result.data.usage
130078
130094
  );
130079
130095
  let choices = result.data.choices.map(
@@ -130096,7 +130112,7 @@ var OpenAIChatInterface = class {
130096
130112
  span?.recordException(err);
130097
130113
  span?.setStatus({ code: SpanStatusCode.ERROR });
130098
130114
  console.error(
130099
- `[OpenAIChatInterface] [${request2.userId}] [chat]: Bad request: ${err.response.data.error.message}`
130115
+ `[${this._name}] [${request2.userId}] [chat]: Bad request: ${err.response.data.error.message}`
130100
130116
  );
130101
130117
  return {
130102
130118
  choices: [
@@ -130113,6 +130129,12 @@ var OpenAIChatInterface = class {
130113
130129
  }
130114
130130
  }
130115
130131
  async *chatStream(request2) {
130132
+ if (this._options.name) {
130133
+ const span = trace.getActiveSpan();
130134
+ if (span) {
130135
+ span.setAttribute("chat.interface.name", this._options.name);
130136
+ }
130137
+ }
130116
130138
  const res = await this._client.chat.completions.create({
130117
130139
  model: request2.model,
130118
130140
  messages: request2.messages.map((m2) => ({
@@ -135623,8 +135645,8 @@ var sloydAiSchema = z.object({
135623
135645
  });
135624
135646
  var aiSchema = z.object({
135625
135647
  chat: z.object({
135626
- provider: z.enum(["openai", "google", "anthropic"]).describe(
135627
- "The provider that should be used by default for Chat AI request models that dont have an associated provider."
135648
+ provider: z.string().describe(
135649
+ "The provider that should be used by default for Chat AI request models that dont have an associated provider. If you want to point to a custom provider, then use the name for the provider."
135628
135650
  ),
135629
135651
  defaultModel: z.string().describe(
135630
135652
  "The model that should be used for Chat AI requests when one is not specified."
@@ -135635,6 +135657,23 @@ var aiSchema = z.object({
135635
135657
  z.object({
135636
135658
  provider: z.enum(["openai", "google", "anthropic"]).optional(),
135637
135659
  model: z.string().nonempty()
135660
+ }),
135661
+ z.object({
135662
+ provider: z.literal("custom-openai-completions").describe(
135663
+ "Defines that the provider points to a custom implementation of the OpenAI Completions API"
135664
+ ),
135665
+ name: z.string().describe(
135666
+ "The name that should be used for this provider"
135667
+ ).nonempty().default("custom-openai-completions"),
135668
+ apiKey: z.string().describe(
135669
+ "The API key that should be used to communicate with the custom API."
135670
+ ).nonempty(),
135671
+ baseUrl: z.string().describe(
135672
+ 'The endpoint that should be used to communicate with the custom API. (e.g. "https://api.openai.com/v1/" for OpenAIs API)'
135673
+ ).nonempty(),
135674
+ models: z.array(z.string().nonempty()).describe(
135675
+ "The list of models that should be mapped to this provider"
135676
+ )
135638
135677
  })
135639
135678
  ])
135640
135679
  ).describe(
@@ -148725,7 +148764,7 @@ var config = new Conf({
148725
148764
  projectName: "casualos-cli"
148726
148765
  });
148727
148766
  var program2 = new Command();
148728
- program2.name("casualos").description("A CLI for CasualOS").version("v3.4.1-alpha.14316240392").option(
148767
+ program2.name("casualos").description("A CLI for CasualOS").version("v3.4.1").option(
148729
148768
  "-e, --endpoint <url>",
148730
148769
  "The endpoint to use for queries. Can be used to override the current endpoint."
148731
148770
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "casualos",
3
- "version": "3.4.1-alpha.14316240392",
3
+ "version": "3.4.1",
4
4
  "description": "Command line interface for CasualOS.",
5
5
  "main": "./dist/index.js",
6
6
  "types": "index.d.ts",
@@ -35,8 +35,8 @@
35
35
  "access": "public"
36
36
  },
37
37
  "dependencies": {
38
- "@casual-simulation/aux-common": "^3.4.1-alpha.14316240392",
39
- "@casual-simulation/aux-records": "^3.4.1-alpha.14316240392",
38
+ "@casual-simulation/aux-common": "^3.4.0",
39
+ "@casual-simulation/aux-records": "^3.4.1",
40
40
  "@octokit/app": "^15.1.0",
41
41
  "@octokit/auth-oauth-device": "^7.1.1",
42
42
  "@octokit/core": "^6.1.2",
@@ -63,5 +63,5 @@
63
63
  "**/*.def",
64
64
  "templates/**"
65
65
  ],
66
- "gitHead": "7ae19d5c713490d6b6887939fa480e16be7111ae"
66
+ "gitHead": "472297626e478e0883a9fc9eb544dc2a336b1afb"
67
67
  }