@polka-codes/runner 0.9.47 → 0.9.49

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/index.js +376 -145
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -22101,9 +22101,9 @@ var require_event_target = __commonJS((exports, module) => {
22101
22101
  }
22102
22102
  Object.defineProperty(MessageEvent.prototype, "data", { enumerable: true });
22103
22103
  var EventTarget = {
22104
- addEventListener(type, handler17, options = {}) {
22104
+ addEventListener(type, handler18, options = {}) {
22105
22105
  for (const listener of this.listeners(type)) {
22106
- if (!options[kForOnEventAttribute] && listener[kListener] === handler17 && !listener[kForOnEventAttribute]) {
22106
+ if (!options[kForOnEventAttribute] && listener[kListener] === handler18 && !listener[kForOnEventAttribute]) {
22107
22107
  return;
22108
22108
  }
22109
22109
  }
@@ -22114,7 +22114,7 @@ var require_event_target = __commonJS((exports, module) => {
22114
22114
  data: isBinary ? data : data.toString()
22115
22115
  });
22116
22116
  event[kTarget] = this;
22117
- callListener(handler17, this, event);
22117
+ callListener(handler18, this, event);
22118
22118
  };
22119
22119
  } else if (type === "close") {
22120
22120
  wrapper = function onClose(code, message) {
@@ -22124,7 +22124,7 @@ var require_event_target = __commonJS((exports, module) => {
22124
22124
  wasClean: this._closeFrameReceived && this._closeFrameSent
22125
22125
  });
22126
22126
  event[kTarget] = this;
22127
- callListener(handler17, this, event);
22127
+ callListener(handler18, this, event);
22128
22128
  };
22129
22129
  } else if (type === "error") {
22130
22130
  wrapper = function onError(error46) {
@@ -22133,28 +22133,28 @@ var require_event_target = __commonJS((exports, module) => {
22133
22133
  message: error46.message
22134
22134
  });
22135
22135
  event[kTarget] = this;
22136
- callListener(handler17, this, event);
22136
+ callListener(handler18, this, event);
22137
22137
  };
22138
22138
  } else if (type === "open") {
22139
22139
  wrapper = function onOpen() {
22140
22140
  const event = new Event("open");
22141
22141
  event[kTarget] = this;
22142
- callListener(handler17, this, event);
22142
+ callListener(handler18, this, event);
22143
22143
  };
22144
22144
  } else {
22145
22145
  return;
22146
22146
  }
22147
22147
  wrapper[kForOnEventAttribute] = !!options[kForOnEventAttribute];
22148
- wrapper[kListener] = handler17;
22148
+ wrapper[kListener] = handler18;
22149
22149
  if (options.once) {
22150
22150
  this.once(type, wrapper);
22151
22151
  } else {
22152
22152
  this.on(type, wrapper);
22153
22153
  }
22154
22154
  },
22155
- removeEventListener(type, handler17) {
22155
+ removeEventListener(type, handler18) {
22156
22156
  for (const listener of this.listeners(type)) {
22157
- if (listener[kListener] === handler17 && !listener[kForOnEventAttribute]) {
22157
+ if (listener[kListener] === handler18 && !listener[kForOnEventAttribute]) {
22158
22158
  this.removeListener(type, listener);
22159
22159
  break;
22160
22160
  }
@@ -22680,16 +22680,16 @@ var require_websocket = __commonJS((exports, module) => {
22680
22680
  }
22681
22681
  return null;
22682
22682
  },
22683
- set(handler17) {
22683
+ set(handler18) {
22684
22684
  for (const listener of this.listeners(method)) {
22685
22685
  if (listener[kForOnEventAttribute]) {
22686
22686
  this.removeListener(method, listener);
22687
22687
  break;
22688
22688
  }
22689
22689
  }
22690
- if (typeof handler17 !== "function")
22690
+ if (typeof handler18 !== "function")
22691
22691
  return;
22692
- this.addEventListener(method, handler17, {
22692
+ this.addEventListener(method, handler18, {
22693
22693
  [kForOnEventAttribute]: true
22694
22694
  });
22695
22695
  }
@@ -23569,7 +23569,7 @@ var {
23569
23569
  Help
23570
23570
  } = import__.default;
23571
23571
  // package.json
23572
- var version = "0.9.47";
23572
+ var version = "0.9.49";
23573
23573
 
23574
23574
  // src/runner.ts
23575
23575
  import { execSync } from "node:child_process";
@@ -36142,36 +36142,12 @@ var configSchema = exports_external.object({
36142
36142
  rules: exports_external.array(exports_external.string()).optional().or(exports_external.string()).optional(),
36143
36143
  excludeFiles: exports_external.array(exports_external.string()).optional()
36144
36144
  }).strict();
36145
- // ../core/src/tools/appendMemory.ts
36146
- var toolInfo = {
36147
- name: "appendMemory",
36148
- description: "Appends content to a memory topic.",
36149
- parameters: exports_external.object({
36150
- topic: exports_external.string().nullish().describe('The topic to append to in memory. Defaults to ":default:".'),
36151
- content: exports_external.string().describe("The content to append.")
36152
- })
36153
- };
36154
- var handler = async (provider, args) => {
36155
- const { topic, content } = toolInfo.parameters.parse(args);
36156
- await provider.appendMemory(topic ?? undefined, content);
36157
- return {
36158
- type: "Reply" /* Reply */,
36159
- message: {
36160
- type: "text",
36161
- value: `Content appended to memory topic '${topic || ""}'.`
36162
- }
36163
- };
36164
- };
36165
- var appendMemory_default = {
36166
- ...toolInfo,
36167
- handler
36168
- };
36169
36145
  // ../core/src/tools/askFollowupQuestion.ts
36170
36146
  var questionObject = exports_external.object({
36171
36147
  prompt: exports_external.string().describe("The text of the question.").meta({ usageValue: "question text here" }),
36172
36148
  options: exports_external.array(exports_external.string()).default([]).describe("Ordered list of suggested answers (omit if none).").meta({ usageValue: "suggested answer here" })
36173
36149
  });
36174
- var toolInfo2 = {
36150
+ var toolInfo = {
36175
36151
  name: "askFollowupQuestion",
36176
36152
  description: "Call this when vital details are missing. Pose each follow-up as one direct, unambiguous question. If it speeds the reply, add up to five short, mutually-exclusive answer options. Group any related questions in the same call to avoid a back-and-forth chain.",
36177
36153
  parameters: exports_external.object({
@@ -36221,7 +36197,7 @@ var toolInfo2 = {
36221
36197
  ]
36222
36198
  })
36223
36199
  };
36224
- var handler2 = async (provider, args) => {
36200
+ var handler = async (provider, args) => {
36225
36201
  if (!provider.askFollowupQuestion) {
36226
36202
  return {
36227
36203
  type: "Error" /* Error */,
@@ -36231,7 +36207,7 @@ var handler2 = async (provider, args) => {
36231
36207
  }
36232
36208
  };
36233
36209
  }
36234
- const { questions } = toolInfo2.parameters.parse(args);
36210
+ const { questions } = toolInfo.parameters.parse(args);
36235
36211
  if (questions.length === 0) {
36236
36212
  return {
36237
36213
  type: "Error" /* Error */,
@@ -36259,11 +36235,11 @@ ${answer}
36259
36235
  };
36260
36236
  };
36261
36237
  var askFollowupQuestion_default = {
36262
- ...toolInfo2,
36263
- handler: handler2
36238
+ ...toolInfo,
36239
+ handler
36264
36240
  };
36265
36241
  // ../core/src/tools/executeCommand.ts
36266
- var toolInfo3 = {
36242
+ var toolInfo2 = {
36267
36243
  name: "executeCommand",
36268
36244
  description: "Run a single CLI command. The command is always executed in the project-root working directory (regardless of earlier commands). Prefer one-off shell commands over wrapper scripts for flexibility. **IMPORTANT**: After an `execute_command` call, you MUST stop and NOT allowed to make further tool calls in the same message.",
36269
36245
  parameters: exports_external.object({
@@ -36290,7 +36266,7 @@ var toolInfo3 = {
36290
36266
  ]
36291
36267
  })
36292
36268
  };
36293
- var handler3 = async (provider, args) => {
36269
+ var handler2 = async (provider, args) => {
36294
36270
  if (!provider.executeCommand) {
36295
36271
  return {
36296
36272
  type: "Error" /* Error */,
@@ -36300,7 +36276,7 @@ var handler3 = async (provider, args) => {
36300
36276
  }
36301
36277
  };
36302
36278
  }
36303
- const { command, requiresApproval } = toolInfo3.parameters.parse(args);
36279
+ const { command, requiresApproval } = toolInfo2.parameters.parse(args);
36304
36280
  try {
36305
36281
  const result = await provider.executeCommand(command, requiresApproval);
36306
36282
  let message = `<command>${command}</command>
@@ -36347,11 +36323,11 @@ ${result.stderr}
36347
36323
  }
36348
36324
  };
36349
36325
  var executeCommand_default = {
36350
- ...toolInfo3,
36351
- handler: handler3
36326
+ ...toolInfo2,
36327
+ handler: handler2
36352
36328
  };
36353
36329
  // ../core/src/tools/fetchUrl.ts
36354
- var toolInfo4 = {
36330
+ var toolInfo3 = {
36355
36331
  name: "fetchUrl",
36356
36332
  description: "Fetch the content located at one or more HTTP(S) URLs and return it in Markdown format. This works for standard web pages as well as raw files (e.g. README.md, source code) hosted on platforms like GitHub.",
36357
36333
  parameters: exports_external.object({
@@ -36384,7 +36360,7 @@ var toolInfo4 = {
36384
36360
  ]
36385
36361
  })
36386
36362
  };
36387
- var handler4 = async (provider, args) => {
36363
+ var handler3 = async (provider, args) => {
36388
36364
  if (!provider.fetchUrl) {
36389
36365
  return {
36390
36366
  type: "Error" /* Error */,
@@ -36394,7 +36370,7 @@ var handler4 = async (provider, args) => {
36394
36370
  }
36395
36371
  };
36396
36372
  }
36397
- const { url: urls } = toolInfo4.parameters.parse(args);
36373
+ const { url: urls } = toolInfo3.parameters.parse(args);
36398
36374
  if (urls.length === 0) {
36399
36375
  return {
36400
36376
  type: "Error" /* Error */,
@@ -36425,6 +36401,38 @@ var handler4 = async (provider, args) => {
36425
36401
  };
36426
36402
  };
36427
36403
  var fetchUrl_default = {
36404
+ ...toolInfo3,
36405
+ handler: handler3
36406
+ };
36407
+ // ../core/src/tools/getTodoItem.ts
36408
+ var toolInfo4 = {
36409
+ name: "getTodoItem",
36410
+ description: "Get a to-do item by its ID.",
36411
+ parameters: exports_external.object({
36412
+ id: exports_external.string().describe("The ID of the to-do item.")
36413
+ })
36414
+ };
36415
+ var handler4 = async (provider, args) => {
36416
+ if (!provider.getTodoItem) {
36417
+ return {
36418
+ type: "Error" /* Error */,
36419
+ message: {
36420
+ type: "error-text",
36421
+ value: "Not possible to get a to-do item."
36422
+ }
36423
+ };
36424
+ }
36425
+ const { id } = toolInfo4.parameters.parse(args);
36426
+ const item = await provider.getTodoItem(id);
36427
+ return {
36428
+ type: "Reply" /* Reply */,
36429
+ message: {
36430
+ type: "json",
36431
+ value: item ?? null
36432
+ }
36433
+ };
36434
+ };
36435
+ var getTodoItem_default = {
36428
36436
  ...toolInfo4,
36429
36437
  handler: handler4
36430
36438
  };
@@ -36499,7 +36507,7 @@ var listFiles_default = {
36499
36507
  // ../core/src/tools/listMemoryTopics.ts
36500
36508
  var toolInfo6 = {
36501
36509
  name: "listMemoryTopics",
36502
- description: "Lists all topics in memory.",
36510
+ description: "Lists all topics in memory. Use this to see what information has been stored and which topics are available to read from.",
36503
36511
  parameters: exports_external.object({})
36504
36512
  };
36505
36513
  var handler6 = async (provider, _args) => {
@@ -36521,15 +36529,88 @@ var listMemoryTopics_default = {
36521
36529
  ...toolInfo6,
36522
36530
  handler: handler6
36523
36531
  };
36524
- // ../core/src/tools/readBinaryFile.ts
36532
+ // ../core/src/tools/todo.ts
36533
+ var TodoStatus = exports_external.enum(["open", "completed", "closed"]);
36534
+ var TodoItemSchema = exports_external.object({
36535
+ id: exports_external.string(),
36536
+ title: exports_external.string(),
36537
+ description: exports_external.string(),
36538
+ relevantFileList: exports_external.array(exports_external.string()),
36539
+ status: TodoStatus
36540
+ });
36541
+ var UpdateTodoItemInputSchema = exports_external.object({
36542
+ operation: exports_external.enum(["add", "update"]),
36543
+ id: exports_external.string().nullish(),
36544
+ parentId: exports_external.string().nullish(),
36545
+ title: exports_external.string().nullish(),
36546
+ description: exports_external.string().nullish(),
36547
+ relevantFileList: exports_external.array(exports_external.string()).nullish(),
36548
+ status: TodoStatus.nullish()
36549
+ }).superRefine((data, ctx) => {
36550
+ if (data.operation === "add") {
36551
+ if (!data.title) {
36552
+ ctx.addIssue({
36553
+ code: "custom",
36554
+ message: 'Title is required for "add" operation',
36555
+ path: ["title"]
36556
+ });
36557
+ }
36558
+ } else if (data.operation === "update") {
36559
+ if (!data.id) {
36560
+ ctx.addIssue({
36561
+ code: "custom",
36562
+ message: 'ID is required for "update" operation',
36563
+ path: ["id"]
36564
+ });
36565
+ }
36566
+ }
36567
+ });
36568
+ var UpdateTodoItemOutputSchema = exports_external.object({
36569
+ id: exports_external.string()
36570
+ });
36571
+
36572
+ // ../core/src/tools/listTodoItems.ts
36525
36573
  var toolInfo7 = {
36574
+ name: "listTodoItems",
36575
+ description: "List all to-do items, sorted by id. If an id is provided, it lists all sub-items for that id. Can be filtered by status.",
36576
+ parameters: exports_external.object({
36577
+ id: exports_external.string().nullish(),
36578
+ status: TodoStatus.nullish()
36579
+ })
36580
+ };
36581
+ var handler7 = async (provider, args) => {
36582
+ if (!provider.listTodoItems) {
36583
+ return {
36584
+ type: "Error" /* Error */,
36585
+ message: {
36586
+ type: "error-text",
36587
+ value: "Not possible to list to-do items."
36588
+ }
36589
+ };
36590
+ }
36591
+ const { id, status } = toolInfo7.parameters.parse(args);
36592
+ const items = await provider.listTodoItems(id, status);
36593
+ return {
36594
+ type: "Reply" /* Reply */,
36595
+ message: {
36596
+ type: "json",
36597
+ value: items
36598
+ }
36599
+ };
36600
+ };
36601
+ var listTodoItems_default = {
36602
+ ...toolInfo7,
36603
+ handler: handler7
36604
+ };
36605
+ // ../core/src/tools/readBinaryFile.ts
36606
+ var toolInfo8 = {
36526
36607
  name: "readBinaryFile",
36527
36608
  description: "Read a binary file from a URL or local path. Use file:// prefix to access local files. This can be used to access non-text files such as PDFs or images.",
36528
36609
  parameters: exports_external.object({
36529
36610
  url: exports_external.string().describe("The URL or local path of the file to read.")
36530
36611
  })
36531
36612
  };
36532
- var handler7 = async (provider, args) => {
36613
+ var handler8 = async (provider, args) => {
36533
36614
  if (!provider.readBinaryFile) {
36534
36615
  return {
36535
36616
  type: "Error" /* Error */,
@@ -36539,7 +36620,7 @@ var handler7 = async (provider, args) => {
36539
36620
  }
36540
36621
  };
36541
36622
  }
36542
- const { url: url2 } = toolInfo7.parameters.parse(args);
36623
+ const { url: url2 } = toolInfo8.parameters.parse(args);
36543
36624
  try {
36544
36625
  const filePart = await provider.readBinaryFile(url2);
36545
36626
  return {
@@ -36568,11 +36649,11 @@ var handler7 = async (provider, args) => {
36568
36649
  }
36569
36650
  };
36570
36651
  var readBinaryFile_default = {
36571
- ...toolInfo7,
36572
- handler: handler7
36652
+ ...toolInfo8,
36653
+ handler: handler8
36573
36654
  };
36574
36655
  // ../core/src/tools/readFile.ts
36575
- var toolInfo8 = {
36656
+ var toolInfo9 = {
36576
36657
  name: "readFile",
36577
36658
  description: "Request to read the contents of one or multiple files at the specified paths. Use comma separated paths to read multiple files. Use this when you need to examine the contents of an existing file you do not know the contents of, for example to analyze code, review text files, or extract information from configuration files. May not be suitable for other types of binary files, as it returns the raw content as a string. Try to list all the potential files are relevent to the task, and then use this tool to read all the relevant files.",
36578
36659
  parameters: exports_external.object({
@@ -36609,7 +36690,7 @@ var toolInfo8 = {
36609
36690
  ]
36610
36691
  })
36611
36692
  };
36612
- var handler8 = async (provider, args) => {
36693
+ var handler9 = async (provider, args) => {
36613
36694
  if (!provider.readFile) {
36614
36695
  return {
36615
36696
  type: "Error" /* Error */,
@@ -36619,7 +36700,7 @@ var handler8 = async (provider, args) => {
36619
36700
  }
36620
36701
  };
36621
36702
  }
36622
- const { path: paths, includeIgnored } = toolInfo8.parameters.parse(args);
36703
+ const { path: paths, includeIgnored } = toolInfo9.parameters.parse(args);
36623
36704
  const resp = [];
36624
36705
  for (const path of paths) {
36625
36706
  const fileContent = await provider.readFile(path, includeIgnored);
@@ -36644,19 +36725,19 @@ var handler8 = async (provider, args) => {
36644
36725
  };
36645
36726
  };
36646
36727
  var readFile_default = {
36647
- ...toolInfo8,
36648
- handler: handler8
36728
+ ...toolInfo9,
36729
+ handler: handler9
36649
36730
  };
36650
36731
  // ../core/src/tools/readMemory.ts
36651
- var toolInfo9 = {
36732
+ var toolInfo10 = {
36652
36733
  name: "readMemory",
36653
- description: "Reads content from a memory topic.",
36734
+ description: "Reads content from a memory topic. Use this to retrieve information stored in previous steps. If no topic is specified, reads from the default topic.",
36654
36735
  parameters: exports_external.object({
36655
36736
  topic: exports_external.string().optional().describe('The topic to read from memory. Defaults to ":default:".')
36656
36737
  })
36657
36738
  };
36658
- var handler9 = async (provider, args) => {
36659
- const { topic } = toolInfo9.parameters.parse(args);
36739
+ var handler10 = async (provider, args) => {
36740
+ const { topic } = toolInfo10.parameters.parse(args);
36660
36741
  const content = await provider.readMemory(topic);
36661
36742
  if (content) {
36662
36743
  return {
@@ -36678,11 +36759,11 @@ ${content}
36678
36759
  };
36679
36760
  };
36680
36761
  var readMemory_default = {
36681
- ...toolInfo9,
36682
- handler: handler9
36762
+ ...toolInfo10,
36763
+ handler: handler10
36683
36764
  };
36684
36765
  // ../core/src/tools/removeFile.ts
36685
- var toolInfo10 = {
36766
+ var toolInfo11 = {
36686
36767
  name: "removeFile",
36687
36768
  description: "Request to remove a file at the specified path.",
36688
36769
  parameters: exports_external.object({
@@ -36698,7 +36779,7 @@ var toolInfo10 = {
36698
36779
  ]
36699
36780
  })
36700
36781
  };
36701
- var handler10 = async (provider, args) => {
36782
+ var handler11 = async (provider, args) => {
36702
36783
  if (!provider.removeFile) {
36703
36784
  return {
36704
36785
  type: "Error" /* Error */,
@@ -36708,7 +36789,7 @@ var handler10 = async (provider, args) => {
36708
36789
  }
36709
36790
  };
36710
36791
  }
36711
- const parsed = toolInfo10.parameters.safeParse(args);
36792
+ const parsed = toolInfo11.parameters.safeParse(args);
36712
36793
  if (!parsed.success) {
36713
36794
  return {
36714
36795
  type: "Error" /* Error */,
@@ -36729,29 +36810,6 @@ var handler10 = async (provider, args) => {
36729
36810
  };
36730
36811
  };
36731
36812
  var removeFile_default = {
36732
- ...toolInfo10,
36733
- handler: handler10
36734
- };
36735
- // ../core/src/tools/removeMemory.ts
36736
- var toolInfo11 = {
36737
- name: "removeMemory",
36738
- description: "Removes a topic from memory.",
36739
- parameters: exports_external.object({
36740
- topic: exports_external.string().optional().describe('The topic to remove from memory. Defaults to ":default:".')
36741
- })
36742
- };
36743
- var handler11 = async (provider, args) => {
36744
- const { topic } = toolInfo11.parameters.parse(args);
36745
- await provider.removeMemory(topic);
36746
- return {
36747
- type: "Reply" /* Reply */,
36748
- message: {
36749
- type: "text",
36750
- value: `Memory topic '${topic || ""}' removed.`
36751
- }
36752
- };
36753
- };
36754
- var removeMemory_default = {
36755
36813
  ...toolInfo11,
36756
36814
  handler: handler11
36757
36815
  };
@@ -36800,7 +36858,7 @@ var renameFile_default = {
36800
36858
  };
36801
36859
  // ../core/src/tools/utils/replaceInFile.ts
36802
36860
  var replaceInFile = (fileContent, diff) => {
36803
- const blockPattern = /<<<<<+ SEARCH>?\s*\r?\n([\s\S]*?)\r?\n=======[ \t]*\r?\n([\s\S]*?)\r?\n?>>>>>+ REPLACE/g;
36861
+ const blockPattern = /^\s*<<<<<+\s*SEARCH>?\s*\r?\n([\s\S]*?)\r?\n=======[ \t]*\r?\n([\s\S]*?)\r?\n?>>>>>+\s*REPLACE\s*$/gm;
36804
36862
  const blocks = [];
36805
36863
  for (let match = blockPattern.exec(diff);match !== null; match = blockPattern.exec(diff)) {
36806
36864
  blocks.push({ search: match[1], replace: match[2] });
@@ -37060,32 +37118,8 @@ var replaceInFile_default = {
37060
37118
  ...toolInfo13,
37061
37119
  handler: handler13
37062
37120
  };
37063
- // ../core/src/tools/replaceMemory.ts
37064
- var toolInfo14 = {
37065
- name: "replaceMemory",
37066
- description: "Replaces content of a memory topic.",
37067
- parameters: exports_external.object({
37068
- topic: exports_external.string().optional().describe('The topic to replace in memory. Defaults to ":default:".'),
37069
- content: exports_external.string().describe("The new content.")
37070
- })
37071
- };
37072
- var handler14 = async (provider, args) => {
37073
- const { topic, content } = toolInfo14.parameters.parse(args);
37074
- await provider.replaceMemory(topic, content);
37075
- return {
37076
- type: "Reply" /* Reply */,
37077
- message: {
37078
- type: "text",
37079
- value: `Memory topic '${topic || ""}' replaced.`
37080
- }
37081
- };
37082
- };
37083
- var replaceMemory_default = {
37084
- ...toolInfo14,
37085
- handler: handler14
37086
- };
37087
37121
  // ../core/src/tools/searchFiles.ts
37088
- var toolInfo15 = {
37122
+ var toolInfo14 = {
37089
37123
  name: "searchFiles",
37090
37124
  description: "Request to perform a regex search across files in a specified directory, outputting context-rich results that include surrounding lines. This tool searches for patterns or specific content across multiple files, displaying each match with encapsulating context.",
37091
37125
  parameters: exports_external.object({
@@ -37109,7 +37143,7 @@ var toolInfo15 = {
37109
37143
  ]
37110
37144
  })
37111
37145
  };
37112
- var handler15 = async (provider, args) => {
37146
+ var handler14 = async (provider, args) => {
37113
37147
  if (!provider.searchFiles) {
37114
37148
  return {
37115
37149
  type: "Error" /* Error */,
@@ -37119,7 +37153,7 @@ var handler15 = async (provider, args) => {
37119
37153
  }
37120
37154
  };
37121
37155
  }
37122
- const parsed = toolInfo15.parameters.safeParse(args);
37156
+ const parsed = toolInfo14.parameters.safeParse(args);
37123
37157
  if (!parsed.success) {
37124
37158
  return {
37125
37159
  type: "Error" /* Error */,
@@ -37157,11 +37191,112 @@ ${files.join(`
37157
37191
  }
37158
37192
  };
37159
37193
  var searchFiles_default = {
37194
+ ...toolInfo14,
37195
+ handler: handler14
37196
+ };
37197
+ // ../core/src/tools/updateMemory.ts
37198
+ var toolInfo15 = {
37199
+ name: "updateMemory",
37200
+ description: 'Appends, replaces, or removes content from a memory topic. Use "append" to add to existing content, "replace" to overwrite entirely, or "remove" to delete a topic. Memory persists across tool calls within a workflow.',
37201
+ parameters: exports_external.object({
37202
+ operation: exports_external.enum(["append", "replace", "remove"]).describe("The operation to perform."),
37203
+ topic: exports_external.string().nullish().describe('The topic to update in memory. Defaults to ":default:".'),
37204
+ content: exports_external.string().optional().describe("The content for append or replace operations. Must be omitted for remove operation.")
37205
+ }).superRefine((data, ctx) => {
37206
+ if (data.operation === "append" || data.operation === "replace") {
37207
+ if (data.content === undefined) {
37208
+ ctx.addIssue({
37209
+ code: "custom",
37210
+ message: 'Content is required for "append" and "replace" operations.',
37211
+ path: ["content"]
37212
+ });
37213
+ }
37214
+ } else if (data.operation === "remove") {
37215
+ if (data.content !== undefined) {
37216
+ ctx.addIssue({
37217
+ code: "custom",
37218
+ message: 'Content must not be provided for "remove" operation.',
37219
+ path: ["content"]
37220
+ });
37221
+ }
37222
+ }
37223
+ })
37224
+ };
37225
+ var handler15 = async (provider, args) => {
37226
+ if (!provider.updateMemory) {
37227
+ return {
37228
+ type: "Error" /* Error */,
37229
+ message: {
37230
+ type: "error-text",
37231
+ value: "Memory operations are not supported by the current provider."
37232
+ }
37233
+ };
37234
+ }
37235
+ const params = toolInfo15.parameters.parse(args);
37236
+ await provider.updateMemory(params.operation, params.topic ?? undefined, "content" in params ? params.content : undefined);
37237
+ switch (params.operation) {
37238
+ case "append":
37239
+ return {
37240
+ type: "Reply" /* Reply */,
37241
+ message: {
37242
+ type: "text",
37243
+ value: `Content appended to memory topic '${params.topic || ":default:"}'.`
37244
+ }
37245
+ };
37246
+ case "replace":
37247
+ return {
37248
+ type: "Reply" /* Reply */,
37249
+ message: {
37250
+ type: "text",
37251
+ value: `Memory topic '${params.topic || ":default:"}' replaced.`
37252
+ }
37253
+ };
37254
+ case "remove":
37255
+ return {
37256
+ type: "Reply" /* Reply */,
37257
+ message: {
37258
+ type: "text",
37259
+ value: `Memory topic '${params.topic || ":default:"}' removed.`
37260
+ }
37261
+ };
37262
+ }
37263
+ };
37264
+ var updateMemory_default = {
37160
37265
  ...toolInfo15,
37161
37266
  handler: handler15
37162
37267
  };
37163
- // ../core/src/tools/writeToFile.ts
37268
+ // ../core/src/tools/updateTodoItem.ts
37164
37269
  var toolInfo16 = {
37270
+ name: "updateTodoItem",
37271
+ description: "Add or update a to-do item.",
37272
+ parameters: UpdateTodoItemInputSchema
37273
+ };
37274
+ var handler16 = async (provider, args) => {
37275
+ if (!provider.updateTodoItem) {
37276
+ return {
37277
+ type: "Error" /* Error */,
37278
+ message: {
37279
+ type: "error-text",
37280
+ value: "Not possible to update a to-do item."
37281
+ }
37282
+ };
37283
+ }
37284
+ const input = toolInfo16.parameters.parse(args);
37285
+ const result = await provider.updateTodoItem(input);
37286
+ return {
37287
+ type: "Reply" /* Reply */,
37288
+ message: {
37289
+ type: "json",
37290
+ value: result
37291
+ }
37292
+ };
37293
+ };
37294
+ var updateTodoItem_default = {
37295
+ ...toolInfo16,
37296
+ handler: handler16
37297
+ };
37298
+ // ../core/src/tools/writeToFile.ts
37299
+ var toolInfo17 = {
37165
37300
  name: "writeToFile",
37166
37301
  description: "Request to write content to a file at the specified path. If the file exists, it will be overwritten with the provided content. If the file doesn't exist, it will be created. This tool will automatically create any directories needed to write the file. Ensure that the output content does not include incorrect escaped character patterns such as `&lt;`, `&gt;`, or `&amp;`. Also ensure there is no unwanted CDATA tags in the content.",
37167
37302
  parameters: exports_external.object({
@@ -37190,7 +37325,7 @@ export default App;
37190
37325
  ]
37191
37326
  })
37192
37327
  };
37193
- var handler16 = async (provider, args) => {
37328
+ var handler17 = async (provider, args) => {
37194
37329
  if (!provider.writeFile) {
37195
37330
  return {
37196
37331
  type: "Error" /* Error */,
@@ -37200,7 +37335,7 @@ var handler16 = async (provider, args) => {
37200
37335
  }
37201
37336
  };
37202
37337
  }
37203
- const parsed = toolInfo16.parameters.safeParse(args);
37338
+ const parsed = toolInfo17.parameters.safeParse(args);
37204
37339
  if (!parsed.success) {
37205
37340
  return {
37206
37341
  type: "Error" /* Error */,
@@ -37224,8 +37359,8 @@ var handler16 = async (provider, args) => {
37224
37359
  };
37225
37360
  };
37226
37361
  var writeToFile_default = {
37227
- ...toolInfo16,
37228
- handler: handler16
37362
+ ...toolInfo17,
37363
+ handler: handler17
37229
37364
  };
37230
37365
  // ../core/src/UsageMeter.ts
37231
37366
  class UsageMeter {
@@ -39101,15 +39236,15 @@ function useKeypress(userHandler) {
39101
39236
  signal.current = userHandler;
39102
39237
  useEffect((rl) => {
39103
39238
  let ignore = false;
39104
- const handler17 = withUpdates((_input, event) => {
39239
+ const handler18 = withUpdates((_input, event) => {
39105
39240
  if (ignore)
39106
39241
  return;
39107
39242
  signal.current(event, rl);
39108
39243
  });
39109
- rl.input.on("keypress", handler17);
39244
+ rl.input.on("keypress", handler18);
39110
39245
  return () => {
39111
39246
  ignore = true;
39112
- rl.input.removeListener("keypress", handler17);
39247
+ rl.input.removeListener("keypress", handler18);
39113
39248
  };
39114
39249
  }, []);
39115
39250
  }
@@ -39268,16 +39403,16 @@ class Emitter {
39268
39403
 
39269
39404
  class SignalExitBase {
39270
39405
  }
39271
- var signalExitWrap = (handler17) => {
39406
+ var signalExitWrap = (handler18) => {
39272
39407
  return {
39273
39408
  onExit(cb, opts) {
39274
- return handler17.onExit(cb, opts);
39409
+ return handler18.onExit(cb, opts);
39275
39410
  },
39276
39411
  load() {
39277
- return handler17.load();
39412
+ return handler18.load();
39278
39413
  },
39279
39414
  unload() {
39280
- return handler17.unload();
39415
+ return handler18.unload();
39281
39416
  }
39282
39417
  };
39283
39418
  };
@@ -40078,27 +40213,122 @@ async function searchFiles(path, regex, filePattern, cwd, excludeFiles) {
40078
40213
  var getProvider = (options = {}) => {
40079
40214
  const ig = import_ignore2.default().add(options.excludeFiles ?? []);
40080
40215
  const memoryStore = {};
40216
+ const todoItems = [];
40081
40217
  const defaultMemoryTopic = ":default:";
40082
40218
  const provider2 = {
40219
+ listTodoItems: async (id, status) => {
40220
+ let items;
40221
+ if (!id) {
40222
+ items = todoItems.filter((i) => !i.id.includes("."));
40223
+ } else {
40224
+ const parent = todoItems.find((i) => i.id === id);
40225
+ if (!parent) {
40226
+ throw new Error(`To-do item with id ${id} not found`);
40227
+ }
40228
+ items = todoItems.filter((i) => i.id.startsWith(`${id}.`) && i.id.split(".").length === id.split(".").length + 1);
40229
+ }
40230
+ if (status) {
40231
+ items = items.filter((item) => item.status === status);
40232
+ }
40233
+ items.sort((a, b) => {
40234
+ const aParts = a.id.split(".");
40235
+ const bParts = b.id.split(".");
40236
+ const len = Math.min(aParts.length, bParts.length);
40237
+ for (let i = 0;i < len; i++) {
40238
+ const comparison = aParts[i].localeCompare(bParts[i], undefined, { numeric: true });
40239
+ if (comparison !== 0) {
40240
+ return comparison;
40241
+ }
40242
+ }
40243
+ return aParts.length - bParts.length;
40244
+ });
40245
+ return items;
40246
+ },
40247
+ getTodoItem: async (id) => {
40248
+ const item = todoItems.find((i) => i.id === id);
40249
+ if (!item) {
40250
+ throw new Error(`To-do item with id ${id} not found`);
40251
+ }
40252
+ const subItems = todoItems.filter((i) => i.id.startsWith(`${id}.`) && i.id.split(".").length === id.split(".").length + 1).map(({ id: id2, title }) => ({ id: id2, title }));
40253
+ return { ...item, subItems };
40254
+ },
40255
+ updateTodoItem: async (input) => {
40256
+ if (input.operation === "add") {
40257
+ const { parentId, title, description, relevantFileList } = input;
40258
+ if (!title) {
40259
+ throw new Error("Title is required for add operation");
40260
+ }
40261
+ let newId;
40262
+ if (parentId) {
40263
+ const parent = todoItems.find((i) => i.id === parentId);
40264
+ if (!parent) {
40265
+ throw new Error(`Parent to-do item with id ${parentId} not found`);
40266
+ }
40267
+ const childItems = todoItems.filter((i) => i.id.startsWith(`${parentId}.`) && i.id.split(".").length === parentId.split(".").length + 1);
40268
+ newId = `${parentId}.${childItems.length + 1}`;
40269
+ } else {
40270
+ const rootItems = todoItems.filter((i) => !i.id.includes("."));
40271
+ newId = `${rootItems.length + 1}`;
40272
+ }
40273
+ const newItem = {
40274
+ id: newId,
40275
+ title,
40276
+ description: description ?? "",
40277
+ relevantFileList: relevantFileList ?? [],
40278
+ status: "open"
40279
+ };
40280
+ todoItems.push(newItem);
40281
+ return { id: newId };
40282
+ } else {
40283
+ const { id } = input;
40284
+ if (!id) {
40285
+ throw new Error("ID is required for update operation");
40286
+ }
40287
+ const item = todoItems.find((i) => i.id === id);
40288
+ if (!item) {
40289
+ throw new Error(`To-do item with id ${id} not found`);
40290
+ }
40291
+ if (input.title != null) {
40292
+ item.title = input.title;
40293
+ }
40294
+ if (input.description != null) {
40295
+ item.description = input.description ?? "";
40296
+ }
40297
+ if (input.relevantFileList != null) {
40298
+ item.relevantFileList = input.relevantFileList;
40299
+ }
40300
+ if (input.status != null) {
40301
+ item.status = input.status;
40302
+ }
40303
+ return { id };
40304
+ }
40305
+ },
40083
40306
  listMemoryTopics: async () => {
40084
40307
  return Object.keys(memoryStore);
40085
40308
  },
40086
40309
  readMemory: async (topic = defaultMemoryTopic) => {
40087
40310
  return memoryStore[topic];
40088
40311
  },
40089
- appendMemory: async (topic = defaultMemoryTopic, content) => {
40090
- if (memoryStore[topic]) {
40091
- memoryStore[topic] += content;
40092
- } else {
40093
- memoryStore[topic] = content;
40312
+ updateMemory: async (operation, topic, content) => {
40313
+ const memoryTopic = topic ?? defaultMemoryTopic;
40314
+ switch (operation) {
40315
+ case "append":
40316
+ if (content === undefined) {
40317
+ throw new Error("Content is required for append operation.");
40318
+ }
40319
+ memoryStore[memoryTopic] = (memoryStore[memoryTopic] || "") + content;
40320
+ break;
40321
+ case "replace":
40322
+ if (content === undefined) {
40323
+ throw new Error("Content is required for replace operation.");
40324
+ }
40325
+ memoryStore[memoryTopic] = content;
40326
+ break;
40327
+ case "remove":
40328
+ delete memoryStore[memoryTopic];
40329
+ break;
40094
40330
  }
40095
40331
  },
40096
- replaceMemory: async (topic = defaultMemoryTopic, content) => {
40097
- memoryStore[topic] = content;
40098
- },
40099
- removeMemory: async (topic = defaultMemoryTopic) => {
40100
- delete memoryStore[topic];
40101
- },
40102
40332
  readFile: async (path, includeIgnored) => {
40103
40333
  if (!includeIgnored && ig.ignores(path)) {
40104
40334
  throw new Error(`Not allow to access file ${path}`);
@@ -40246,7 +40476,8 @@ var getProvider = (options = {}) => {
40246
40476
  return provider2;
40247
40477
  };
40248
40478
  // ../cli-shared/src/utils/eventHandler.ts
40249
- var toolCallStats = new Map;
40479
+ var taskToolCallStats = new Map;
40480
+ var globalToolCallStats = new Map;
40250
40481
  // ../../node_modules/.bun/ws@8.18.3/node_modules/ws/wrapper.mjs
40251
40482
  var import_stream = __toESM(require_stream(), 1);
40252
40483
  var import_receiver = __toESM(require_receiver(), 1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polka-codes/runner",
3
- "version": "0.9.47",
3
+ "version": "0.9.49",
4
4
  "license": "AGPL-3.0",
5
5
  "author": "github@polka.codes",
6
6
  "type": "module",