@codelia/core 0.1.74 → 0.1.75

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -6173,103 +6173,6 @@ var getDefaultSystemPromptPath = () => promptPath;
6173
6173
 
6174
6174
  // src/tools/define.ts
6175
6175
  var import_zod = require("zod");
6176
- var schemaAllowsNull = (schema) => {
6177
- if (schema.type === "null") return true;
6178
- if (Array.isArray(schema.type) && schema.type.includes("null")) return true;
6179
- return [...schema.anyOf ?? [], ...schema.oneOf ?? []].some(
6180
- (variant) => variant !== true && variant !== false && schemaAllowsNull(variant)
6181
- );
6182
- };
6183
- var withOptionalNullHint = (description) => {
6184
- const hint = "Pass null to omit this optional value and use its default behavior.";
6185
- if (!description) return hint;
6186
- return description.includes(hint) ? description : `${description} ${hint}`;
6187
- };
6188
- var nullableOptionalProperty = (schema) => {
6189
- if (schemaAllowsNull(schema)) {
6190
- return { ...schema, description: withOptionalNullHint(schema.description) };
6191
- }
6192
- const { description, ...inner } = schema;
6193
- return {
6194
- description: withOptionalNullHint(description),
6195
- anyOf: [inner, { type: "null" }]
6196
- };
6197
- };
6198
- var toStrictToolSchema = (schema) => {
6199
- const originalRequired = new Set(schema.required ?? []);
6200
- const next = { ...schema };
6201
- if (next.type === "object") {
6202
- next.additionalProperties ??= false;
6203
- if (next.properties) {
6204
- const properties = {};
6205
- for (const [key, property] of Object.entries(next.properties)) {
6206
- const normalized = toStrictToolSchema(property);
6207
- properties[key] = originalRequired.has(key) ? normalized : nullableOptionalProperty(normalized);
6208
- }
6209
- next.properties = properties;
6210
- const propertyKeys = Object.keys(properties);
6211
- if (propertyKeys.length > 0) next.required = propertyKeys;
6212
- }
6213
- }
6214
- if (next.items) {
6215
- next.items = Array.isArray(next.items) ? next.items.map((item) => toStrictToolSchema(item)) : toStrictToolSchema(next.items);
6216
- }
6217
- if (next.anyOf) {
6218
- next.anyOf = next.anyOf.map(
6219
- (item) => item === true || item === false ? item : toStrictToolSchema(item)
6220
- );
6221
- }
6222
- if (next.oneOf) {
6223
- next.oneOf = next.oneOf.map(
6224
- (item) => item === true || item === false ? item : toStrictToolSchema(item)
6225
- );
6226
- }
6227
- if (next.allOf) {
6228
- next.allOf = next.allOf.map(
6229
- (item) => item === true || item === false ? item : toStrictToolSchema(item)
6230
- );
6231
- }
6232
- if (next.not) {
6233
- next.not = toStrictToolSchema(next.not);
6234
- }
6235
- if (next.additionalProperties && next.additionalProperties !== true) {
6236
- next.additionalProperties = toStrictToolSchema(
6237
- next.additionalProperties
6238
- );
6239
- }
6240
- return next;
6241
- };
6242
- var normalizeOptionalNulls = (value, schema) => {
6243
- if (Array.isArray(value) && schema.items && !Array.isArray(schema.items)) {
6244
- return value.map(
6245
- (item) => normalizeOptionalNulls(item, schema.items)
6246
- );
6247
- }
6248
- if (!value || typeof value !== "object" || Array.isArray(value)) return value;
6249
- const normalized = { ...value };
6250
- if (schema.type === "object" && schema.properties) {
6251
- const required = new Set(schema.required ?? []);
6252
- for (const [key, property] of Object.entries(schema.properties)) {
6253
- if (!(key in normalized)) continue;
6254
- if (normalized[key] === null && !required.has(key)) {
6255
- delete normalized[key];
6256
- continue;
6257
- }
6258
- normalized[key] = normalizeOptionalNulls(
6259
- normalized[key],
6260
- property
6261
- );
6262
- }
6263
- }
6264
- for (const variant of [...schema.anyOf ?? [], ...schema.oneOf ?? []]) {
6265
- if (variant === true || variant === false) continue;
6266
- Object.assign(
6267
- normalized,
6268
- normalizeOptionalNulls(normalized, variant)
6269
- );
6270
- }
6271
- return normalized;
6272
- };
6273
6176
  var withTopLevelObjectTypeForObjectUnions = (schema) => {
6274
6177
  if (schema.type !== void 0) return schema;
6275
6178
  const variants = (Array.isArray(schema.anyOf) && schema.anyOf.length > 0 ? schema.anyOf : Array.isArray(schema.oneOf) && schema.oneOf.length > 0 ? schema.oneOf : null) ?? null;
@@ -6294,17 +6197,15 @@ function defineTool(toolOptions) {
6294
6197
  target: "draft-07",
6295
6198
  io: "input"
6296
6199
  });
6297
- const strictParameters = withTopLevelObjectTypeForObjectUnions(
6298
- toStrictToolSchema(parameters)
6299
- );
6200
+ const modelParameters = withTopLevelObjectTypeForObjectUnions(parameters);
6300
6201
  return {
6301
6202
  name: toolOptions.name,
6302
6203
  description: toolOptions.description,
6303
6204
  definition: {
6304
6205
  name: toolOptions.name,
6305
6206
  description: toolOptions.description,
6306
- parameters: strictParameters,
6307
- strict: true
6207
+ parameters: modelParameters,
6208
+ strict: false
6308
6209
  },
6309
6210
  executeRaw: (rawArgsJson, ctx) => {
6310
6211
  let rawArgs;
@@ -6315,9 +6216,7 @@ function defineTool(toolOptions) {
6315
6216
  `Invalid tool arguments JSON for ${toolOptions.name}: ${String(error)}`
6316
6217
  );
6317
6218
  }
6318
- const parsed = toolOptions.input.safeParse(
6319
- normalizeOptionalNulls(rawArgs, parameters)
6320
- );
6219
+ const parsed = toolOptions.input.safeParse(rawArgs);
6321
6220
  if (!parsed.success) {
6322
6221
  throw new Error(
6323
6222
  `Tool input validation failed for ${toolOptions.name}: ${parsed.error.message}`
package/dist/index.js CHANGED
@@ -6108,103 +6108,6 @@ var getDefaultSystemPromptPath = () => promptPath;
6108
6108
 
6109
6109
  // src/tools/define.ts
6110
6110
  import { toJSONSchema } from "zod";
6111
- var schemaAllowsNull = (schema) => {
6112
- if (schema.type === "null") return true;
6113
- if (Array.isArray(schema.type) && schema.type.includes("null")) return true;
6114
- return [...schema.anyOf ?? [], ...schema.oneOf ?? []].some(
6115
- (variant) => variant !== true && variant !== false && schemaAllowsNull(variant)
6116
- );
6117
- };
6118
- var withOptionalNullHint = (description) => {
6119
- const hint = "Pass null to omit this optional value and use its default behavior.";
6120
- if (!description) return hint;
6121
- return description.includes(hint) ? description : `${description} ${hint}`;
6122
- };
6123
- var nullableOptionalProperty = (schema) => {
6124
- if (schemaAllowsNull(schema)) {
6125
- return { ...schema, description: withOptionalNullHint(schema.description) };
6126
- }
6127
- const { description, ...inner } = schema;
6128
- return {
6129
- description: withOptionalNullHint(description),
6130
- anyOf: [inner, { type: "null" }]
6131
- };
6132
- };
6133
- var toStrictToolSchema = (schema) => {
6134
- const originalRequired = new Set(schema.required ?? []);
6135
- const next = { ...schema };
6136
- if (next.type === "object") {
6137
- next.additionalProperties ??= false;
6138
- if (next.properties) {
6139
- const properties = {};
6140
- for (const [key, property] of Object.entries(next.properties)) {
6141
- const normalized = toStrictToolSchema(property);
6142
- properties[key] = originalRequired.has(key) ? normalized : nullableOptionalProperty(normalized);
6143
- }
6144
- next.properties = properties;
6145
- const propertyKeys = Object.keys(properties);
6146
- if (propertyKeys.length > 0) next.required = propertyKeys;
6147
- }
6148
- }
6149
- if (next.items) {
6150
- next.items = Array.isArray(next.items) ? next.items.map((item) => toStrictToolSchema(item)) : toStrictToolSchema(next.items);
6151
- }
6152
- if (next.anyOf) {
6153
- next.anyOf = next.anyOf.map(
6154
- (item) => item === true || item === false ? item : toStrictToolSchema(item)
6155
- );
6156
- }
6157
- if (next.oneOf) {
6158
- next.oneOf = next.oneOf.map(
6159
- (item) => item === true || item === false ? item : toStrictToolSchema(item)
6160
- );
6161
- }
6162
- if (next.allOf) {
6163
- next.allOf = next.allOf.map(
6164
- (item) => item === true || item === false ? item : toStrictToolSchema(item)
6165
- );
6166
- }
6167
- if (next.not) {
6168
- next.not = toStrictToolSchema(next.not);
6169
- }
6170
- if (next.additionalProperties && next.additionalProperties !== true) {
6171
- next.additionalProperties = toStrictToolSchema(
6172
- next.additionalProperties
6173
- );
6174
- }
6175
- return next;
6176
- };
6177
- var normalizeOptionalNulls = (value, schema) => {
6178
- if (Array.isArray(value) && schema.items && !Array.isArray(schema.items)) {
6179
- return value.map(
6180
- (item) => normalizeOptionalNulls(item, schema.items)
6181
- );
6182
- }
6183
- if (!value || typeof value !== "object" || Array.isArray(value)) return value;
6184
- const normalized = { ...value };
6185
- if (schema.type === "object" && schema.properties) {
6186
- const required = new Set(schema.required ?? []);
6187
- for (const [key, property] of Object.entries(schema.properties)) {
6188
- if (!(key in normalized)) continue;
6189
- if (normalized[key] === null && !required.has(key)) {
6190
- delete normalized[key];
6191
- continue;
6192
- }
6193
- normalized[key] = normalizeOptionalNulls(
6194
- normalized[key],
6195
- property
6196
- );
6197
- }
6198
- }
6199
- for (const variant of [...schema.anyOf ?? [], ...schema.oneOf ?? []]) {
6200
- if (variant === true || variant === false) continue;
6201
- Object.assign(
6202
- normalized,
6203
- normalizeOptionalNulls(normalized, variant)
6204
- );
6205
- }
6206
- return normalized;
6207
- };
6208
6111
  var withTopLevelObjectTypeForObjectUnions = (schema) => {
6209
6112
  if (schema.type !== void 0) return schema;
6210
6113
  const variants = (Array.isArray(schema.anyOf) && schema.anyOf.length > 0 ? schema.anyOf : Array.isArray(schema.oneOf) && schema.oneOf.length > 0 ? schema.oneOf : null) ?? null;
@@ -6229,17 +6132,15 @@ function defineTool(toolOptions) {
6229
6132
  target: "draft-07",
6230
6133
  io: "input"
6231
6134
  });
6232
- const strictParameters = withTopLevelObjectTypeForObjectUnions(
6233
- toStrictToolSchema(parameters)
6234
- );
6135
+ const modelParameters = withTopLevelObjectTypeForObjectUnions(parameters);
6235
6136
  return {
6236
6137
  name: toolOptions.name,
6237
6138
  description: toolOptions.description,
6238
6139
  definition: {
6239
6140
  name: toolOptions.name,
6240
6141
  description: toolOptions.description,
6241
- parameters: strictParameters,
6242
- strict: true
6142
+ parameters: modelParameters,
6143
+ strict: false
6243
6144
  },
6244
6145
  executeRaw: (rawArgsJson, ctx) => {
6245
6146
  let rawArgs;
@@ -6250,9 +6151,7 @@ function defineTool(toolOptions) {
6250
6151
  `Invalid tool arguments JSON for ${toolOptions.name}: ${String(error)}`
6251
6152
  );
6252
6153
  }
6253
- const parsed = toolOptions.input.safeParse(
6254
- normalizeOptionalNulls(rawArgs, parameters)
6255
- );
6154
+ const parsed = toolOptions.input.safeParse(rawArgs);
6256
6155
  if (!parsed.success) {
6257
6156
  throw new Error(
6258
6157
  `Tool input validation failed for ${toolOptions.name}: ${parsed.error.message}`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codelia/core",
3
- "version": "0.1.74",
3
+ "version": "0.1.75",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",
@@ -25,8 +25,8 @@
25
25
  },
26
26
  "dependencies": {
27
27
  "@anthropic-ai/sdk": "^0.110.0",
28
- "@codelia/config": "0.1.74",
29
- "@codelia/shared-types": "0.1.74",
28
+ "@codelia/config": "0.1.75",
29
+ "@codelia/shared-types": "0.1.75",
30
30
  "@google-cloud/vertexai": "^1.10.0",
31
31
  "@google/genai": "^1.43.0",
32
32
  "json-schema": "^0.4.0",