agentic-api 1.0.4 → 1.0.5

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.
@@ -31,12 +31,12 @@ const toolPullContentDigestor = {
31
31
  properties: {
32
32
  path: {
33
33
  type: "string",
34
- description: "Absolute or relative path of the file to read (e.g., 'https:....html', 'file://...', 'https://.../file.pdf')."
34
+ description: "Absolute or relative path, or a unique identifier of the file to read (e.g., 'https:....html', 'file://...', 'https://.../file.pdf')."
35
35
  },
36
36
  template: {
37
37
  type: "string",
38
38
  description: "Type of processing to apply to the chunk (e.g., 'facts', 'compress', 'semantic', 'minutes').",
39
- enum: ["facts", "compress", "semantic", "minutes"]
39
+ enum: ["facts", "compress", "semantic", "minutes", "custom"]
40
40
  },
41
41
  position: {
42
42
  type: "number",
@@ -61,39 +61,43 @@ const toolPullContentDigestor = {
61
61
  const loadContentChunk = async (path, position, chunkSize, cache, userid) => {
62
62
  //FIXME: multiple users access to the cache with different position!
63
63
  const loader = async (path, cache, userid) => {
64
- const cacheKey = `content:${path}:${userid}`;
64
+ const cacheKey = `content:${path}`;
65
65
  const value = await cache.get(cacheKey);
66
66
  if (value) {
67
67
  return value;
68
68
  }
69
- if (path.startsWith("file://")) {
69
+ if ((0, fs_1.existsSync)(path)) {
70
70
  const fileContent = (0, fs_1.readFileSync)(path, "utf8");
71
- const value = { content: fileContent, position: 0, key: cacheKey };
71
+ const value = { content: fileContent, position: { [userid]: 0 }, key: cacheKey };
72
72
  await cache.set(cacheKey, value);
73
73
  return value;
74
74
  }
75
- if (path.startsWith("http://") || path.startsWith("https://")) {
75
+ else if (path.startsWith("http://") || path.startsWith("https://")) {
76
76
  const response = await fetch(path);
77
77
  const fileContent = await response.text();
78
- const value = { content: fileContent, position: 0, key: cacheKey };
78
+ const value = { content: fileContent, position: { [userid]: 0 }, key: cacheKey };
79
79
  await cache.set(cacheKey, value);
80
80
  return value;
81
81
  }
82
82
  //
83
83
  // if not a file or url, return the path as content
84
- return { content: path, position: 0, key: cacheKey };
84
+ return { content: path, position: { [userid]: 0 }, key: cacheKey };
85
85
  };
86
86
  //
87
87
  // load asset content
88
88
  const value = await loader(path, cache, userid);
89
- const startPos = value.position;
90
- value.position = startPos + chunkSize;
89
+ const hasNextLN = value.content.indexOf('\n', value.position[userid] + chunkSize - 2);
90
+ // Determine the start position for the next chunk.
91
+ // If there is no next newline, use the current position; otherwise, start after the next newline.
92
+ const startPos = value.position[userid];
93
+ const nextPos = (hasNextLN == -1) ? startPos + chunkSize : startPos + hasNextLN + 1;
94
+ value.position[userid] = startPos + nextPos;
91
95
  await cache.set(value.key, value);
92
96
  if (startPos >= value.content.length) {
93
- return { content: 'EOF', position: startPos };
97
+ return { content: 'EOF', position: nextPos };
94
98
  }
95
99
  if (startPos + chunkSize + 1 > value.content.length) {
96
- return { content: value.content.slice(startPos) + "\nEOF", position: startPos };
100
+ return { content: value.content.slice(startPos) + "\nEOF", position: nextPos };
97
101
  }
98
102
  const endPos = Math.min(startPos + chunkSize, value.content.length);
99
103
  return { content: value.content.slice(startPos, endPos), position: endPos };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentic-api",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "API pour l'orchestration d'agents intelligents avec séquences et escalades automatiques",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",