casualos 3.4.1-alpha.14318904853 → 3.4.4-alpha.14502478455

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 +63 -18
  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.14318904853"
98084
+ false ? void 0 : "v3.4.4-alpha.14502478455"
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.14318904853"
98102
+ false ? void 0 : "v3.4.4-alpha.14502478455"
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.14318904853"
98120
+ false ? void 0 : "v3.4.4-alpha.14502478455"
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.14318904853"
105072
+ false ? void 0 : "v3.4.4-alpha.14502478455"
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.14318904853"
105150
+ false ? void 0 : "v3.4.4-alpha.14502478455"
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.14318904853"
105159
+ false ? void 0 : "v3.4.4-alpha.14502478455"
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.14318904853"
117266
+ false ? void 0 : "v3.4.4-alpha.14502478455"
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.14318904853" : void 0,
119672
- versionHash: true ? "ef806e4fe519d1e572a721a6e35671d16462d913" : void 0
119671
+ version: true ? "v3.4.4-alpha.14502478455" : void 0,
119672
+ versionHash: true ? "b407322cf3257d6e15ddbc347b6e3152e1a45fdc" : void 0
119673
119673
  };
119674
119674
  })
119675
119675
  };
@@ -130023,17 +130023,35 @@ 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
  });
130038
+ this._additionalProperties = options.additionalProperties ?? {};
130031
130039
  }
130032
130040
  async chat(request2) {
130033
130041
  try {
130042
+ if (this._options.name) {
130043
+ const span = trace.getActiveSpan();
130044
+ if (span) {
130045
+ span.setAttribute(
130046
+ "chat.interface.name",
130047
+ this._options.name
130048
+ );
130049
+ }
130050
+ }
130034
130051
  const result = await axios_default.post(
130035
- "https://api.openai.com/v1/chat/completions",
130052
+ `${this._baseUrl}chat/completions`,
130036
130053
  {
130054
+ ...this._additionalProperties,
130037
130055
  model: request2.model,
130038
130056
  messages: request2.messages.map((m2) => ({
130039
130057
  role: m2.role,
@@ -130070,10 +130088,10 @@ var OpenAIChatInterface = class {
130070
130088
  }
130071
130089
  );
130072
130090
  console.log(
130073
- `[OpenAIChatInterface] [${request2.userId}] [chat]: Total tokens: ${result.data.usage.total_tokens}`
130091
+ `[${this._name}] [${request2.userId}] [chat]: Total tokens: ${result.data.usage.total_tokens}`
130074
130092
  );
130075
130093
  console.log(
130076
- `[OpenAIChatInterface] [${request2.userId}] [chat]: Usage:`,
130094
+ `[${this._name}] [${request2.userId}] [chat]: Usage:`,
130077
130095
  result.data.usage
130078
130096
  );
130079
130097
  let choices = result.data.choices.map(
@@ -130087,7 +130105,7 @@ var OpenAIChatInterface = class {
130087
130105
  );
130088
130106
  return {
130089
130107
  choices,
130090
- totalTokens: result.data.usage.total_tokens
130108
+ totalTokens: result.data.usage?.total_tokens ?? 0
130091
130109
  };
130092
130110
  } catch (err) {
130093
130111
  if (axios_default.isAxiosError(err)) {
@@ -130096,7 +130114,7 @@ var OpenAIChatInterface = class {
130096
130114
  span?.recordException(err);
130097
130115
  span?.setStatus({ code: SpanStatusCode.ERROR });
130098
130116
  console.error(
130099
- `[OpenAIChatInterface] [${request2.userId}] [chat]: Bad request: ${err.response.data.error.message}`
130117
+ `[${this._name}] [${request2.userId}] [chat]: Bad request: ${err.response.data.error.message}`
130100
130118
  );
130101
130119
  return {
130102
130120
  choices: [
@@ -130113,7 +130131,14 @@ var OpenAIChatInterface = class {
130113
130131
  }
130114
130132
  }
130115
130133
  async *chatStream(request2) {
130134
+ if (this._options.name) {
130135
+ const span = trace.getActiveSpan();
130136
+ if (span) {
130137
+ span.setAttribute("chat.interface.name", this._options.name);
130138
+ }
130139
+ }
130116
130140
  const res = await this._client.chat.completions.create({
130141
+ ...this._additionalProperties,
130117
130142
  model: request2.model,
130118
130143
  messages: request2.messages.map((m2) => ({
130119
130144
  role: m2.role,
@@ -135623,8 +135648,8 @@ var sloydAiSchema = z.object({
135623
135648
  });
135624
135649
  var aiSchema = z.object({
135625
135650
  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."
135651
+ provider: z.string().describe(
135652
+ "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
135653
  ),
135629
135654
  defaultModel: z.string().describe(
135630
135655
  "The model that should be used for Chat AI requests when one is not specified."
@@ -135635,6 +135660,26 @@ var aiSchema = z.object({
135635
135660
  z.object({
135636
135661
  provider: z.enum(["openai", "google", "anthropic"]).optional(),
135637
135662
  model: z.string().nonempty()
135663
+ }),
135664
+ z.object({
135665
+ provider: z.literal("custom-openai-completions").describe(
135666
+ "Defines that the provider points to a custom implementation of the OpenAI Completions API"
135667
+ ),
135668
+ name: z.string().describe(
135669
+ "The name that should be used for this provider"
135670
+ ).nonempty().default("custom-openai-completions"),
135671
+ apiKey: z.string().describe(
135672
+ "The API key that should be used to communicate with the custom API."
135673
+ ).nonempty(),
135674
+ baseUrl: z.string().describe(
135675
+ 'The endpoint that should be used to communicate with the custom API. (e.g. "https://api.openai.com/v1/" for OpenAIs API)'
135676
+ ).nonempty(),
135677
+ models: z.array(z.string().nonempty()).describe(
135678
+ "The list of models that should be mapped to this provider"
135679
+ ),
135680
+ additionalProperties: z.object({}).passthrough().describe(
135681
+ "The additional properties that should be included in requests."
135682
+ ).optional()
135638
135683
  })
135639
135684
  ])
135640
135685
  ).describe(
@@ -148725,7 +148770,7 @@ var config = new Conf({
148725
148770
  projectName: "casualos-cli"
148726
148771
  });
148727
148772
  var program2 = new Command();
148728
- program2.name("casualos").description("A CLI for CasualOS").version("v3.4.1-alpha.14318904853").option(
148773
+ program2.name("casualos").description("A CLI for CasualOS").version("v3.4.4-alpha.14502478455").option(
148729
148774
  "-e, --endpoint <url>",
148730
148775
  "The endpoint to use for queries. Can be used to override the current endpoint."
148731
148776
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "casualos",
3
- "version": "3.4.1-alpha.14318904853",
3
+ "version": "3.4.4-alpha.14502478455",
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.14318904853",
39
- "@casual-simulation/aux-records": "^3.4.1-alpha.14318904853",
38
+ "@casual-simulation/aux-common": "^3.4.0",
39
+ "@casual-simulation/aux-records": "^3.4.4-alpha.14502478455",
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": "ef806e4fe519d1e572a721a6e35671d16462d913"
66
+ "gitHead": "b407322cf3257d6e15ddbc347b6e3152e1a45fdc"
67
67
  }