codebuff 1.0.231 → 1.0.232

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 (58) hide show
  1. package/dist/cli-handlers/inititalization-flow.d.ts +1 -0
  2. package/dist/cli-handlers/inititalization-flow.js +24 -0
  3. package/dist/cli-handlers/inititalization-flow.js.map +1 -0
  4. package/dist/cli.js +7 -0
  5. package/dist/cli.js.map +1 -1
  6. package/dist/client.d.ts +6 -6
  7. package/dist/client.js +29 -34
  8. package/dist/client.js.map +1 -1
  9. package/dist/code-map/tsconfig.tsbuildinfo +1 -1
  10. package/dist/common/actions.d.ts +54 -54
  11. package/dist/common/bigquery/client.js +5 -4
  12. package/dist/common/bigquery/client.js.map +1 -1
  13. package/dist/common/bigquery/schema.d.ts +1 -0
  14. package/dist/common/bigquery/schema.js.map +1 -1
  15. package/dist/common/billing/balance-calculator.d.ts +2 -2
  16. package/dist/common/billing/quota-manager.d.ts +29 -0
  17. package/dist/common/billing/quota-manager.js +251 -0
  18. package/dist/common/billing/quota-manager.js.map +1 -0
  19. package/dist/common/constants.d.ts +7 -5
  20. package/dist/common/constants.js +14 -9
  21. package/dist/common/constants.js.map +1 -1
  22. package/dist/common/json-config/__tests__/stringify-schema.test.js +7 -7
  23. package/dist/common/json-config/__tests__/stringify-schema.test.js.map +1 -1
  24. package/dist/common/json-config/constants.d.ts +5 -0
  25. package/dist/common/json-config/constants.js +11 -5
  26. package/dist/common/json-config/constants.js.map +1 -1
  27. package/dist/common/json-config/parser.d.ts +1 -1
  28. package/dist/common/json-config/parser.js +16 -9
  29. package/dist/common/json-config/parser.js.map +1 -1
  30. package/dist/common/json-config/stringify-schema.d.ts +1 -1
  31. package/dist/common/json-config/stringify-schema.js +51 -36
  32. package/dist/common/json-config/stringify-schema.js.map +1 -1
  33. package/dist/common/logger.d.ts +1 -0
  34. package/dist/common/logger.js +7 -0
  35. package/dist/common/logger.js.map +1 -0
  36. package/dist/common/types/usage.d.ts +4 -4
  37. package/dist/common/util/constants.d.ts +1 -0
  38. package/dist/common/util/constants.js +7 -0
  39. package/dist/common/util/constants.js.map +1 -0
  40. package/dist/common/util/helpers.d.ts +1 -0
  41. package/dist/common/util/helpers.js +6 -0
  42. package/dist/common/util/helpers.js.map +1 -0
  43. package/dist/common/util/token-counter.d.ts +3 -0
  44. package/dist/common/util/token-counter.js +27 -0
  45. package/dist/common/util/token-counter.js.map +1 -0
  46. package/dist/common/util/tools.d.ts +2 -0
  47. package/dist/common/util/tools.js +13 -0
  48. package/dist/common/util/tools.js.map +1 -0
  49. package/dist/common/websockets/websocket-schema.d.ts +104 -104
  50. package/dist/dev-process-manager.d.ts +1 -1
  51. package/dist/dev-process-manager.js +1 -1
  52. package/dist/index.js +2 -2
  53. package/dist/index.js.map +1 -1
  54. package/dist/menu.js +12 -11
  55. package/dist/menu.js.map +1 -1
  56. package/dist/tool-handlers.js +16 -2
  57. package/dist/tool-handlers.js.map +1 -1
  58. package/package.json +2 -1
@@ -1,13 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CodebuffConfigSchema = exports.StartupProcessSchema = void 0;
3
+ exports.CodebuffConfigSchema = exports.StartupProcessSchema = exports.codebuffConfigFileBackup = exports.codebuffConfigFile = void 0;
4
4
  const zod_1 = require("zod");
5
+ exports.codebuffConfigFile = 'codebuff.json';
6
+ exports.codebuffConfigFileBackup = 'codebuff.jsonc';
5
7
  exports.StartupProcessSchema = zod_1.z
6
8
  .object({
7
9
  name: zod_1.z
8
10
  .string()
9
11
  .min(1, 'Process name is required')
10
- .describe('A user-friendly name for the process.'),
12
+ .describe('A user-friendly name for the process. Should be one word and unique.'),
11
13
  command: zod_1.z
12
14
  .string()
13
15
  .min(1, 'Command is required')
@@ -30,13 +32,17 @@ exports.StartupProcessSchema = zod_1.z
30
32
  .optional()
31
33
  .describe('Path to write process stderr output. If not specified, output is not stored.'),
32
34
  })
33
- .describe('Defines a single startup process. This validates the structure of an object representing a command that Codebuff can run automatically when it starts.');
35
+ .describe('Defines a single startup process.');
34
36
  exports.CodebuffConfigSchema = zod_1.z
35
37
  .object({
38
+ description: zod_1.z
39
+ .any()
40
+ .optional()
41
+ .describe('Does nothing. Put any thing you want here!'),
36
42
  startupProcesses: zod_1.z
37
43
  .array(exports.StartupProcessSchema)
38
44
  .optional()
39
- .describe('An array of startup processes, each validated by the StartupProcessSchema.'),
45
+ .describe('An array of startup processes.'),
40
46
  })
41
- .describe('Defines the overall Codebuff configuration file (e.g., codebuff.json). This schema defines the top-level structure of the configuration.');
47
+ .describe(`Defines the overall Codebuff configuration file (e.g., ${exports.codebuffConfigFile}). This schema defines the top-level structure of the configuration.`);
42
48
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/json-config/constants.ts"],"names":[],"mappings":";;;AAAA,6BAAuB;AAEV,QAAA,oBAAoB,GAAG,OAAC;KAClC,MAAM,CAAC;IACN,IAAI,EAAE,OAAC;SACJ,MAAM,EAAE;SACR,GAAG,CAAC,CAAC,EAAE,0BAA0B,CAAC;SAClC,QAAQ,CAAC,uCAAuC,CAAC;IACpD,OAAO,EAAE,OAAC;SACP,MAAM,EAAE;SACR,GAAG,CAAC,CAAC,EAAE,qBAAqB,CAAC;SAC7B,QAAQ,CAAC,sCAAsC,CAAC;IACnD,GAAG,EAAE,OAAC;SACH,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CAAC,sDAAsD,CAAC;IACnE,OAAO,EAAE,OAAC;SACP,OAAO,EAAE;SACT,QAAQ,EAAE;SACV,OAAO,CAAC,IAAI,CAAC;SACb,QAAQ,CAAC,qCAAqC,CAAC;IAClD,UAAU,EAAE,OAAC;SACV,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CACP,8EAA8E,CAC/E;IACH,UAAU,EAAE,OAAC;SACV,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CAC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IACN,WAAW,EAAE,OAAC;SACX,GAAG,EAAE;SACL,QAAQ,EAAE;SACV,QAAQ,CAAC,4CAA4C,CAAC;IACzD,gBAAgB,EAAE,OAAC;SAChB,KAAK,CAAC,4BAAoB,CAAC;SAC3B,QAAQ,EAAE;SACV,QAAQ,CAAC,gCAAgC,CAAC;CAC9C,CAAC;KACD,QAAQ,CACP,0DAA0D,0BAAkB,sEAAsE,CACnJ,CAAA"}
@@ -1,6 +1,6 @@
1
1
  import { CodebuffConfig } from './constants';
2
2
  /**
3
- * Loads and validates the codebuff.json configuration file from the project directory.
3
+ * Loads and validates the configuration file from the project directory.
4
4
  * @param projectPath - The root directory of the project
5
5
  * @returns The parsed and validated configuration, or null if no valid config exists
6
6
  */
@@ -4,26 +4,33 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.loadCodebuffConfig = loadCodebuffConfig;
7
- const fs_1 = __importDefault(require("fs"));
7
+ const fs_1 = require("fs");
8
8
  const path_1 = __importDefault(require("path"));
9
+ const jsonc_parser_1 = require("jsonc-parser");
9
10
  const picocolors_1 = require("picocolors");
10
11
  const constants_1 = require("./constants");
11
12
  /**
12
- * Loads and validates the codebuff.json configuration file from the project directory.
13
+ * Loads and validates the configuration file from the project directory.
13
14
  * @param projectPath - The root directory of the project
14
15
  * @returns The parsed and validated configuration, or null if no valid config exists
15
16
  */
16
17
  function loadCodebuffConfig(projectPath) {
17
- const configPath = path_1.default.join(projectPath, 'codebuff.json');
18
- if (!fs_1.default.existsSync(configPath)) {
18
+ const configPathPrimary = path_1.default.join(projectPath, constants_1.codebuffConfigFile);
19
+ const configPathBackup = path_1.default.join(projectPath, constants_1.codebuffConfigFileBackup);
20
+ const configPath = (0, fs_1.existsSync)(configPathBackup)
21
+ ? configPathBackup
22
+ : (0, fs_1.existsSync)(configPathPrimary)
23
+ ? configPathPrimary
24
+ : null;
25
+ if (configPath === null) {
19
26
  return null;
20
27
  }
21
28
  try {
22
- const configContent = fs_1.default.readFileSync(configPath, 'utf-8');
23
- const parsedConfig = JSON.parse(configContent);
29
+ const jsoncContent = (0, fs_1.readFileSync)(configPath, 'utf-8');
30
+ const parsedConfig = (0, jsonc_parser_1.parse)(jsoncContent);
24
31
  const result = constants_1.CodebuffConfigSchema.safeParse(parsedConfig);
25
32
  if (!result.success) {
26
- console.warn((0, picocolors_1.yellow)('Warning: Invalid codebuff.json configuration. Please check the schema:\n' +
33
+ console.warn((0, picocolors_1.yellow)(`Warning: Invalid ${constants_1.codebuffConfigFile} configuration. Please check the schema:\n` +
27
34
  result.error.errors
28
35
  .map((err) => `- ${err.path.join('.')}: ${err.message}`)
29
36
  .join('\n')));
@@ -33,10 +40,10 @@ function loadCodebuffConfig(projectPath) {
33
40
  }
34
41
  catch (error) {
35
42
  if (error instanceof SyntaxError) {
36
- console.warn((0, picocolors_1.yellow)('Warning: Invalid JSON in codebuff.json. Please check the syntax.'));
43
+ console.warn((0, picocolors_1.yellow)(`Warning: Invalid JSON in ${constants_1.codebuffConfigFile}. Please check the syntax.`));
37
44
  }
38
45
  else {
39
- console.warn((0, picocolors_1.yellow)('Warning: Error reading codebuff.json configuration file.'));
46
+ console.warn((0, picocolors_1.yellow)(`Warning: Error reading ${constants_1.codebuffConfigFile} configuration file.`));
40
47
  }
41
48
  return null;
42
49
  }
@@ -1 +1 @@
1
- {"version":3,"file":"parser.js","sourceRoot":"","sources":["../../src/json-config/parser.ts"],"names":[],"mappings":";;;;;AAYA,gDAwCC;AApDD,4CAAmB;AACnB,gDAAuB;AAEvB,2CAAmC;AAEnC,2CAAkE;AAElE;;;;GAIG;AACH,SAAgB,kBAAkB,CAAC,WAAmB;IACpD,MAAM,UAAU,GAAG,cAAI,CAAC,IAAI,CAAC,WAAW,EAAE,eAAe,CAAC,CAAA;IAE1D,IAAI,CAAC,YAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC/B,OAAO,IAAI,CAAA;IAC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AAA,mBAAM,EACJ,0BAA0B,8BAAkB,sBAAsB,CACnE,CACF,CAAA;QACH,CAAC;QACD,OAAO,IAAI,CAAA;IACb,CAAC;AACH,CAAC"}
@@ -7,4 +7,4 @@ import { z } from 'zod';
7
7
  * @param schemaName A name for the root schema.
8
8
  * @returns A string describing the schema structure and field descriptions.
9
9
  */
10
- export declare function stringifySchemaForLLM(schema: z.ZodObject<any>, schemaName: string): string;
10
+ export declare function stringifySchema(schema: z.ZodObject<any>, schemaName: string): string;
@@ -1,67 +1,92 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.stringifySchemaForLLM = stringifySchemaForLLM;
3
+ exports.stringifySchema = stringifySchema;
4
4
  const zod_1 = require("zod");
5
5
  function getSchemaDescription(schema) {
6
6
  return schema.description;
7
7
  }
8
8
  function formatDescription(description) {
9
- return description ? ` (${description})` : '';
9
+ if (!description)
10
+ return '';
11
+ return `(${description})`;
10
12
  }
11
13
  function indent(level) {
12
- return ' '.repeat(level);
14
+ return ' '.repeat(level);
13
15
  }
14
16
  function stringifyZodType(schema, level = 0, fieldName) {
15
17
  const description = getSchemaDescription(schema);
16
18
  const baseIndent = indent(level);
17
- const fieldPrefix = fieldName ? `${fieldName}: ` : '';
19
+ const fieldPrefix = fieldName ? `\`${fieldName}\`:` : '';
20
+ const desc = formatDescription(description);
21
+ // Handle object types
22
+ if (schema instanceof zod_1.z.ZodObject) {
23
+ const shape = schema.shape;
24
+ let output = `${baseIndent}${fieldPrefix}`;
25
+ if (desc)
26
+ output += `\n${indent(level + 1)}${desc}`;
27
+ output += `\n${indent(level + 1)}Object`;
28
+ if (Object.keys(shape).length === 0) {
29
+ output += `\n${baseIndent}{\n${baseIndent}}`;
30
+ return output;
31
+ }
32
+ output += `\n${baseIndent}{\n`;
33
+ for (const key in shape) {
34
+ output += stringifyZodType(shape[key], level + 1, key) + '\n\n';
35
+ }
36
+ output = output.slice(0, -1); // Remove last newline
37
+ output += `${baseIndent}}`;
38
+ return output;
39
+ }
18
40
  // Handle optional types
19
41
  if (schema instanceof zod_1.z.ZodOptional || schema instanceof zod_1.z.ZodNullable) {
20
42
  const innerType = stringifyZodType(schema._def.innerType, level, fieldName);
21
43
  // Remove the field name from the inner type string if present
22
44
  const innerTypeWithoutPrefix = fieldName
23
- ? innerType.replace(`${baseIndent}${fieldPrefix}`, `${baseIndent}`)
45
+ ? innerType.replace(`${baseIndent}\`${fieldName}\`:`, `${baseIndent}`)
24
46
  : innerType;
25
- return `${baseIndent}${fieldPrefix}Optional<${innerTypeWithoutPrefix.trim()}>${formatDescription(description)}`;
47
+ return `${baseIndent}${fieldPrefix}\n${indent(level + 1)}${desc}\n${indent(level + 1)}Optional<${innerTypeWithoutPrefix.trim()}>`;
26
48
  }
27
49
  // Handle default types
28
50
  if (schema instanceof zod_1.z.ZodDefault) {
29
51
  const innerType = stringifyZodType(schema._def.innerType, level, fieldName);
30
52
  // Remove the field name from the inner type string if present
31
53
  const innerTypeWithoutPrefix = fieldName
32
- ? innerType.replace(`${baseIndent}${fieldPrefix}`, `${baseIndent}`)
54
+ ? innerType.replace(`${baseIndent}\`${fieldName}\`:`, `${baseIndent}`)
33
55
  : innerType;
34
56
  const defaultValue = JSON.stringify(schema._def.defaultValue());
35
- return `${baseIndent}${fieldPrefix}Default<${innerTypeWithoutPrefix.trim()}> (default: ${defaultValue})${formatDescription(description)}`;
36
- }
37
- // Handle object types
38
- if (schema instanceof zod_1.z.ZodObject) {
39
- const shape = schema.shape;
40
- let output = `${baseIndent}${fieldPrefix}Object${formatDescription(description)} {\n`;
41
- for (const key in shape) {
42
- output += stringifyZodType(shape[key], level + 1, key) + '\n';
43
- }
44
- output += `${baseIndent}}`;
45
- return output;
57
+ return [
58
+ `${baseIndent}${fieldPrefix}`,
59
+ `${indent(level + 1)}${desc}`,
60
+ `${indent(level + 1)}${innerTypeWithoutPrefix.trim()} (default: ${defaultValue})`,
61
+ ].join('\n');
46
62
  }
47
63
  // Handle array types
48
64
  if (schema instanceof zod_1.z.ZodArray) {
49
- const elementType = stringifyZodType(schema.element, level).trim();
50
- return `${baseIndent}${fieldPrefix}Array<${elementType}>${formatDescription(description)}`;
65
+ const elementType = stringifyZodType(schema.element, level + 2, `${fieldName}.item`).trim();
66
+ return [
67
+ `${baseIndent}${fieldPrefix}`,
68
+ `${indent(level + 1)}${desc}`,
69
+ `${indent(level + 1)}Array<`,
70
+ `${indent(level + 2)}${elementType}`,
71
+ `${indent(level + 1)}>`,
72
+ ].join('\n');
51
73
  }
52
74
  // Handle basic types (string, number, boolean, etc.)
53
75
  if (schema instanceof zod_1.z.ZodString) {
54
- return `${baseIndent}${fieldPrefix}String${formatDescription(description)}`;
76
+ return `${baseIndent}${fieldPrefix}\n${indent(level + 1)}${desc}\n${indent(level + 1)}String`;
55
77
  }
56
78
  if (schema instanceof zod_1.z.ZodBoolean) {
57
- return `${baseIndent}${fieldPrefix}Boolean${formatDescription(description)}`;
79
+ return `${baseIndent}${fieldPrefix}\n${indent(level + 1)}${desc}\n${indent(level + 1)}Boolean`;
58
80
  }
59
81
  if (schema instanceof zod_1.z.ZodNumber) {
60
- return `${baseIndent}${fieldPrefix}Number${formatDescription(description)}`;
82
+ return `${baseIndent}${fieldPrefix}\n${indent(level + 1)}${desc}\n${indent(level + 1)}Number`;
83
+ }
84
+ if (schema instanceof zod_1.z.ZodAny) {
85
+ return `${baseIndent}${fieldPrefix}\n${indent(level + 1)}${desc}\n${indent(level + 1)}Any`;
61
86
  }
62
87
  // Add more basic types as needed (e.g., ZodDate, ZodEnum)
63
88
  // Fallback for unknown types
64
- return `${baseIndent}${fieldPrefix}UnknownType${formatDescription(description)}`;
89
+ return `${baseIndent}${fieldPrefix}\n${indent(level + 1)}${desc}\n${indent(level + 1)}UnknownType`;
65
90
  }
66
91
  /**
67
92
  * Generates a human-readable string representation of a Zod schema,
@@ -71,17 +96,7 @@ function stringifyZodType(schema, level = 0, fieldName) {
71
96
  * @param schemaName A name for the root schema.
72
97
  * @returns A string describing the schema structure and field descriptions.
73
98
  */
74
- function stringifySchemaForLLM(schema, schemaName) {
75
- let output = `Schema: ${schemaName}\n`;
76
- output += stringifyZodType(schema);
77
- return output;
99
+ function stringifySchema(schema, schemaName) {
100
+ return stringifyZodType(schema, 0, schemaName);
78
101
  }
79
- // --- Example Usage ---
80
- /*
81
- console.log('--- StartupProcessSchema ---')
82
- console.log(stringifySchemaForLLM(StartupProcessSchema, 'StartupProcessSchema'))
83
-
84
- console.log('\n--- CodebuffConfigSchema ---')
85
- console.log(stringifySchemaForLLM(CodebuffConfigSchema, 'CodebuffConfigSchema'))
86
- */
87
102
  //# sourceMappingURL=stringify-schema.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"stringify-schema.js","sourceRoot":"","sources":["../../src/json-config/stringify-schema.ts"],"names":[],"mappings":";;AAyFA,sDAOC;AAhGD,6BAAmC;AAEnC,SAAS,oBAAoB,CAAC,MAAkB;IAC9C,OAAO,MAAM,CAAC,WAAW,CAAA;AAC3B,CAAC;AAED,SAAS,iBAAiB,CAAC,WAA+B;IACxD,OAAO,WAAW,CAAC,CAAC,CAAC,KAAK,WAAW,GAAG,CAAC,CAAC,CAAC,EAAE,CAAA;AAC/C,CAAC;AAED,SAAS,MAAM,CAAC,KAAa;IAC3B,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;AAC3B,CAAC;AAED,SAAS,gBAAgB,CACvB,MAAkB,EAClB,QAAgB,CAAC,EACjB,SAAkB;IAElB,MAAM,WAAW,GAAG,oBAAoB,CAAC,MAAM,CAAC,CAAA;IAChD,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC,CAAA;IAChC,MAAM,WAAW,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,IAAI,CAAC,CAAC,CAAC,EAAE,CAAA;IAErD,wBAAwB;IACxB,IAAI,MAAM,YAAY,OAAC,CAAC,WAAW,IAAI,MAAM,YAAY,OAAC,CAAC,WAAW,EAAE,CAAC;Q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,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,IAAI,KAAK,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,QAAQ,CAAA;IAC/F,CAAC;IACD,IAAI,MAAM,YAAY,OAAC,CAAC,UAAU,EAAE,CAAC;QACnC,OAAO,GAAG,UAAU,GAAG,WAAW,KAAK,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,IAAI,KAAK,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,SAAS,CAAA;IAChG,CAAC;IACD,IAAI,MAAM,YAAY,OAAC,CAAC,SAAS,EAAE,CAAC;QAClC,OAAO,GAAG,UAAU,GAAG,WAAW,KAAK,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,IAAI,KAAK,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,QAAQ,CAAA;IAC/F,CAAC;IACD,IAAI,MAAM,YAAY,OAAC,CAAC,MAAM,EAAE,CAAC;QAC/B,OAAO,GAAG,UAAU,GAAG,WAAW,KAAK,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,IAAI,KAAK,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAA;IAC5F,CAAC;IACD,0DAA0D;IAE1D,6BAA6B;IAC7B,OAAO,GAAG,UAAU,GAAG,WAAW,KAAK,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,IAAI,KAAK,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,aAAa,CAAA;AACpG,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,eAAe,CAC7B,MAAwB,EACxB,UAAkB;IAElB,OAAO,gBAAgB,CAAC,MAAM,EAAE,CAAC,EAAE,UAAU,CAAC,CAAA;AAChD,CAAC"}
@@ -0,0 +1 @@
1
+ export declare function withLoggerContext(context: any, logger: any, callback: () => Promise<any>): Promise<any>;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.withLoggerContext = withLoggerContext;
4
+ function withLoggerContext(context, logger, callback) {
5
+ return callback();
6
+ }
7
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":";;AAAA,8CAEC;AAFD,SAAgB,iBAAiB,CAAC,OAAY,EAAE,MAAW,EAAE,QAA4B;IACvF,OAAO,QAAQ,EAAE,CAAA;AACnB,CAAC"}
@@ -7,13 +7,13 @@ export declare const usageDataSchema: z.ZodObject<{
7
7
  netBalance: z.ZodNumber;
8
8
  breakdown: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
9
9
  }, "strip", z.ZodTypeAny, {
10
- totalDebt: number;
11
10
  totalRemaining: number;
11
+ totalDebt: number;
12
12
  netBalance: number;
13
13
  breakdown?: Record<string, number> | undefined;
14
14
  }, {
15
- totalDebt: number;
16
15
  totalRemaining: number;
16
+ totalDebt: number;
17
17
  netBalance: number;
18
18
  breakdown?: Record<string, number> | undefined;
19
19
  }>;
@@ -22,8 +22,8 @@ export declare const usageDataSchema: z.ZodObject<{
22
22
  }, "strip", z.ZodTypeAny, {
23
23
  nextMonthlyGrant: number;
24
24
  balance: {
25
- totalDebt: number;
26
25
  totalRemaining: number;
26
+ totalDebt: number;
27
27
  netBalance: number;
28
28
  breakdown?: Record<string, number> | undefined;
29
29
  };
@@ -32,8 +32,8 @@ export declare const usageDataSchema: z.ZodObject<{
32
32
  }, {
33
33
  nextMonthlyGrant: number;
34
34
  balance: {
35
- totalDebt: number;
36
35
  totalRemaining: number;
36
+ totalDebt: number;
37
37
  netBalance: number;
38
38
  breakdown?: Record<string, number> | undefined;
39
39
  };
@@ -0,0 +1 @@
1
+ export declare function getModelForMode(mode: string): string;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getModelForMode = getModelForMode;
4
+ function getModelForMode(mode) {
5
+ return 'claude-3-sonnet';
6
+ }
7
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/util/constants.ts"],"names":[],"mappings":";;AAAA,0CAEC;AAFD,SAAgB,eAAe,CAAC,IAAY;IAC1C,OAAO,iBAAiB,CAAA;AAC1B,CAAC"}
@@ -0,0 +1 @@
1
+ export declare const sleep: (ms: number) => Promise<unknown>;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sleep = void 0;
4
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
5
+ exports.sleep = sleep;
6
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/util/helpers.ts"],"names":[],"mappings":";;;AAAO,MAAM,KAAK,GAAG,CAAC,EAAU,EAAE,EAAE,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAA;AAA7D,QAAA,KAAK,SAAwD"}
@@ -0,0 +1,3 @@
1
+ export declare function countTokens(text: string): number;
2
+ export declare function countTokensJson(text: string | object): number;
3
+ export declare function countTokensForFiles(files: Record<string, string | null>): Record<string, number>;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.countTokens = countTokens;
4
+ exports.countTokensJson = countTokensJson;
5
+ exports.countTokensForFiles = countTokensForFiles;
6
+ const gpt_4o_1 = require("gpt-tokenizer/esm/model/gpt-4o");
7
+ const ANTHROPIC_TOKEN_FUDGE_FACTOR = 1.35;
8
+ function countTokens(text) {
9
+ try {
10
+ return Math.floor((0, gpt_4o_1.encode)(text).length * ANTHROPIC_TOKEN_FUDGE_FACTOR);
11
+ }
12
+ catch (e) {
13
+ console.error('Error counting tokens', e);
14
+ return Math.ceil(text.length / 3);
15
+ }
16
+ }
17
+ function countTokensJson(text) {
18
+ return countTokens(JSON.stringify(text));
19
+ }
20
+ function countTokensForFiles(files) {
21
+ const tokenCounts = {};
22
+ for (const [filePath, content] of Object.entries(files)) {
23
+ tokenCounts[filePath] = content ? countTokens(content) : 0;
24
+ }
25
+ return tokenCounts;
26
+ }
27
+ //# sourceMappingURL=token-counter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token-counter.js","sourceRoot":"","sources":["../../src/util/token-counter.ts"],"names":[],"mappings":";;AAIA,kCAOC;AAED,0CAEC;AAED,kDAQC;AAzBD,2DAAuD;AAEvD,MAAM,4BAA4B,GAAG,IAAI,CAAA;AAEzC,SAAgB,WAAW,CAAC,IAAY;IACtC,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,IAAA,eAAM,EAAC,IAAI,CAAC,CAAC,MAAM,GAAG,4BAA4B,CAAC,CAAA;IACvE,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,CAAC,KAAK,CAAC,uBAAuB,EAAE,CAAC,CAAC,CAAA;QACzC,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;IACnC,CAAC;AACH,CAAC;AAED,SAAgB,eAAe,CAAC,IAAqB;IACnD,OAAO,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAA;AAC1C,CAAC;AAED,SAAgB,mBAAmB,CACjC,KAAoC;IAEpC,MAAM,WAAW,GAA2B,EAAE,CAAA;IAC9C,KAAK,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACxD,WAAW,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAC5D,CAAC;IACD,OAAO,WAAW,CAAA;AACpB,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { Message } from 'src/actions';
2
+ export declare const didClientUseTool: (message: Message) => boolean;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.didClientUseTool = void 0;
4
+ const ts_pattern_1 = require("ts-pattern");
5
+ const constants_1 = require("src/constants");
6
+ const didClientUseTool = (message) => (0, ts_pattern_1.match)(message)
7
+ .with({
8
+ role: 'user',
9
+ content: ts_pattern_1.P.string.and(ts_pattern_1.P.when((content) => content.includes(constants_1.TOOL_RESULT_MARKER))),
10
+ }, () => true)
11
+ .otherwise(() => false);
12
+ exports.didClientUseTool = didClientUseTool;
13
+ //# sourceMappingURL=tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.js","sourceRoot":"","sources":["../../src/util/tools.ts"],"names":[],"mappings":";;;AACA,2CAAqC;AACrC,6CAAkD;AAE3C,MAAM,gBAAgB,GAAG,CAAC,OAAgB,EAAE,EAAE,CACnD,IAAA,kBAAK,EAAC,OAAO,CAAC;KACX,IAAI,CACH;IACE,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,cAAC,CAAC,MAAM,CAAC,GAAG,CACnB,cAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAE,OAAkB,CAAC,QAAQ,CAAC,8BAAkB,CAAC,CAAC,CACtE;CACF,EACD,GAAG,EAAE,CAAC,IAAI,CACX;KACA,SAAS,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAA;AAXd,QAAA,gBAAgB,oBAWF"}