@revealui/ai 0.2.7 → 0.2.9
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/LICENSE +104 -17
- package/README.md +2 -2
- package/dist/a2a/card.d.ts +1 -1
- package/dist/a2a/card.d.ts.map +1 -1
- package/dist/a2a/card.js +4 -4
- package/dist/a2a/handler.d.ts +4 -4
- package/dist/a2a/handler.js +5 -5
- package/dist/a2a/index.d.ts +1 -1
- package/dist/a2a/index.js +1 -1
- package/dist/audit/emitter.d.ts +1 -1
- package/dist/audit/emitter.js +2 -2
- package/dist/audit/index.d.ts +2 -2
- package/dist/audit/index.js +2 -2
- package/dist/audit/store.d.ts +2 -2
- package/dist/audit/store.js +2 -2
- package/dist/client/errors.d.ts +13 -0
- package/dist/client/errors.d.ts.map +1 -0
- package/dist/client/errors.js +28 -0
- package/dist/client/hooks/useAgentContext.d.ts.map +1 -1
- package/dist/client/hooks/useAgentContext.js +6 -5
- package/dist/client/hooks/useAgentStream.d.ts +2 -2
- package/dist/client/hooks/useAgentStream.js +3 -3
- package/dist/client/hooks/useEpisodicMemory.d.ts.map +1 -1
- package/dist/client/hooks/useEpisodicMemory.js +6 -5
- package/dist/client/hooks/useWorkingMemory.d.ts.map +1 -1
- package/dist/client/hooks/useWorkingMemory.js +7 -6
- package/dist/embeddings/index.d.ts +1 -1
- package/dist/embeddings/index.js +4 -4
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -2
- package/dist/inference/context-budget.d.ts +1 -1
- package/dist/inference/context-budget.js +4 -4
- package/dist/inference/index.d.ts +1 -1
- package/dist/inference/index.js +1 -1
- package/dist/inference/runRag.d.ts +3 -3
- package/dist/inference/runRag.d.ts.map +1 -1
- package/dist/inference/runRag.js +1 -1
- package/dist/inference/task-decomposer.d.ts +1 -1
- package/dist/inference/task-decomposer.d.ts.map +1 -1
- package/dist/inference/task-decomposer.js +3 -3
- package/dist/inference/tool-result-compressor.d.ts +1 -1
- package/dist/inference/tool-result-compressor.js +1 -1
- package/dist/ingestion/{cms-indexer.d.ts → admin-indexer.d.ts} +12 -12
- package/dist/ingestion/admin-indexer.d.ts.map +1 -0
- package/dist/ingestion/{cms-indexer.js → admin-indexer.js} +9 -9
- package/dist/ingestion/bm25.d.ts +1 -1
- package/dist/ingestion/bm25.js +1 -1
- package/dist/ingestion/file-parsers.d.ts +1 -1
- package/dist/ingestion/file-parsers.d.ts.map +1 -1
- package/dist/ingestion/file-parsers.js +36 -17
- package/dist/ingestion/hybrid-search.d.ts +1 -1
- package/dist/ingestion/hybrid-search.js +1 -1
- package/dist/ingestion/index.d.ts +1 -1
- package/dist/ingestion/index.d.ts.map +1 -1
- package/dist/ingestion/index.js +1 -1
- package/dist/ingestion/rag-vector-service.d.ts +1 -1
- package/dist/ingestion/rag-vector-service.js +1 -1
- package/dist/ingestion/reranker.d.ts +1 -1
- package/dist/ingestion/reranker.js +1 -1
- package/dist/ingestion/text-splitter.d.ts +1 -1
- package/dist/ingestion/text-splitter.js +2 -2
- package/dist/llm/cache-utils.d.ts.map +1 -1
- package/dist/llm/cache-utils.js +1 -17
- package/dist/llm/client.d.ts +8 -13
- package/dist/llm/client.d.ts.map +1 -1
- package/dist/llm/client.js +12 -60
- package/dist/llm/key-validator.d.ts +1 -1
- package/dist/llm/key-validator.js +8 -8
- package/dist/llm/providers/base.d.ts +2 -2
- package/dist/llm/providers/groq.d.ts +2 -2
- package/dist/llm/providers/groq.d.ts.map +1 -1
- package/dist/llm/providers/groq.js +4 -4
- package/dist/llm/providers/inference-snaps.d.ts +5 -5
- package/dist/llm/providers/inference-snaps.d.ts.map +1 -1
- package/dist/llm/providers/inference-snaps.js +6 -6
- package/dist/llm/providers/ollama.d.ts +2 -2
- package/dist/llm/providers/ollama.d.ts.map +1 -1
- package/dist/llm/providers/ollama.js +3 -3
- package/dist/llm/providers/{openai.d.ts → openai-compat.d.ts} +8 -7
- package/dist/llm/providers/openai-compat.d.ts.map +1 -0
- package/dist/llm/providers/{openai.js → openai-compat.js} +13 -17
- package/dist/llm/providers/vultr.d.ts.map +1 -1
- package/dist/llm/providers/vultr.js +1 -0
- package/dist/llm/server.d.ts +1 -3
- package/dist/llm/server.d.ts.map +1 -1
- package/dist/llm/server.js +1 -3
- package/dist/llm/token-counter.d.ts.map +1 -1
- package/dist/llm/token-counter.js +11 -8
- package/dist/llm/workspace-provider-config.d.ts +1 -1
- package/dist/llm/workspace-provider-config.d.ts.map +1 -1
- package/dist/llm/workspace-provider-config.js +1 -1
- package/dist/memory/crdt/or-set.d.ts +12 -0
- package/dist/memory/crdt/or-set.d.ts.map +1 -1
- package/dist/memory/crdt/or-set.js +27 -0
- package/dist/memory/index.d.ts +1 -0
- package/dist/memory/index.d.ts.map +1 -1
- package/dist/memory/index.js +1 -0
- package/dist/memory/persistence/crdt-persistence.d.ts +21 -1
- package/dist/memory/persistence/crdt-persistence.d.ts.map +1 -1
- package/dist/memory/persistence/crdt-persistence.js +67 -0
- package/dist/memory/preferences/user-preferences-manager.d.ts.map +1 -1
- package/dist/memory/preferences/user-preferences-manager.js +11 -1
- package/dist/memory/stores/episodic-memory.js +2 -2
- package/dist/memory/stores/working-memory.d.ts +7 -2
- package/dist/memory/stores/working-memory.d.ts.map +1 -1
- package/dist/memory/stores/working-memory.js +31 -17
- package/dist/memory/sync/index.d.ts +2 -0
- package/dist/memory/sync/index.d.ts.map +1 -0
- package/dist/memory/sync/index.js +1 -0
- package/dist/memory/sync/sync-manager.d.ts +104 -0
- package/dist/memory/sync/sync-manager.d.ts.map +1 -0
- package/dist/memory/sync/sync-manager.js +137 -0
- package/dist/memory/utils/validation.js +1 -1
- package/dist/memory/vector/vector-memory-service.d.ts +1 -1
- package/dist/memory/vector/vector-memory-service.js +1 -1
- package/dist/orchestration/agent.d.ts +2 -2
- package/dist/orchestration/defaults.d.ts +1 -1
- package/dist/orchestration/defaults.js +1 -1
- package/dist/orchestration/orchestrator.d.ts +3 -3
- package/dist/orchestration/orchestrator.js +3 -3
- package/dist/orchestration/runtime.d.ts +1 -1
- package/dist/orchestration/runtime.js +1 -1
- package/dist/orchestration/streaming-runtime.d.ts +2 -2
- package/dist/orchestration/streaming-runtime.js +2 -2
- package/dist/orchestration/ticket-agent.d.ts +11 -11
- package/dist/orchestration/ticket-agent.d.ts.map +1 -1
- package/dist/orchestration/ticket-agent.js +10 -10
- package/dist/skills/catalog/vercel-catalog.d.ts.map +1 -1
- package/dist/skills/catalog/vercel-catalog.js +7 -4
- package/dist/skills/loader/github-loader.d.ts.map +1 -1
- package/dist/skills/loader/github-loader.js +2 -0
- package/dist/skills/loader/local-loader.js +1 -1
- package/dist/skills/loader/vercel-loader.d.ts.map +1 -1
- package/dist/skills/loader/vercel-loader.js +2 -0
- package/dist/skills/parser/skill-md-parser.js +2 -2
- package/dist/skills/registry/skill-registry.js +1 -1
- package/dist/skills/types.d.ts +6 -6
- package/dist/templates/prompt-spec.js +1 -1
- package/dist/templates/skill-spec.js +1 -1
- package/dist/tools/{cms → admin}/collection-tools.d.ts +2 -2
- package/dist/tools/admin/collection-tools.d.ts.map +1 -0
- package/dist/tools/{cms → admin}/collection-tools.js +8 -8
- package/dist/tools/{cms → admin}/factory.d.ts +11 -11
- package/dist/tools/admin/factory.d.ts.map +1 -0
- package/dist/tools/{cms → admin}/factory.js +4 -4
- package/dist/tools/{cms → admin}/global-tools.d.ts +1 -1
- package/dist/tools/admin/global-tools.d.ts.map +1 -0
- package/dist/tools/{cms → admin}/global-tools.js +4 -4
- package/dist/tools/{cms → admin}/index.d.ts +4 -4
- package/dist/tools/admin/index.d.ts.map +1 -0
- package/dist/tools/{cms → admin}/index.js +3 -3
- package/dist/tools/{cms → admin}/media-tools.d.ts +1 -1
- package/dist/tools/admin/media-tools.d.ts.map +1 -0
- package/dist/tools/{cms → admin}/media-tools.js +4 -4
- package/dist/tools/{cms → admin}/user-tools.d.ts +1 -1
- package/dist/tools/admin/user-tools.d.ts.map +1 -0
- package/dist/tools/{cms → admin}/user-tools.js +1 -1
- package/dist/tools/coding/file-edit.d.ts +1 -1
- package/dist/tools/coding/file-edit.js +2 -2
- package/dist/tools/coding/file-glob.d.ts +1 -1
- package/dist/tools/coding/file-glob.d.ts.map +1 -1
- package/dist/tools/coding/file-glob.js +2 -1
- package/dist/tools/coding/file-grep.d.ts +1 -1
- package/dist/tools/coding/file-grep.d.ts.map +1 -1
- package/dist/tools/coding/file-grep.js +2 -1
- package/dist/tools/coding/file-read.d.ts +1 -1
- package/dist/tools/coding/file-read.d.ts.map +1 -1
- package/dist/tools/coding/file-read.js +15 -9
- package/dist/tools/coding/file-write.d.ts +1 -1
- package/dist/tools/coding/file-write.js +1 -1
- package/dist/tools/coding/git-ops.d.ts +1 -1
- package/dist/tools/coding/git-ops.d.ts.map +1 -1
- package/dist/tools/coding/git-ops.js +5 -7
- package/dist/tools/coding/index.d.ts +1 -1
- package/dist/tools/coding/index.d.ts.map +1 -1
- package/dist/tools/coding/lint-fix.d.ts +1 -1
- package/dist/tools/coding/lint-fix.d.ts.map +1 -1
- package/dist/tools/coding/lint-fix.js +8 -4
- package/dist/tools/coding/project-context.d.ts +1 -1
- package/dist/tools/coding/project-context.d.ts.map +1 -1
- package/dist/tools/coding/project-context.js +25 -24
- package/dist/tools/coding/safety.d.ts +1 -1
- package/dist/tools/coding/safety.d.ts.map +1 -1
- package/dist/tools/coding/shell-exec.d.ts +1 -1
- package/dist/tools/coding/shell-exec.js +1 -1
- package/dist/tools/coding/test-runner.d.ts +1 -1
- package/dist/tools/coding/test-runner.d.ts.map +1 -1
- package/dist/tools/coding/test-runner.js +12 -7
- package/dist/tools/deduplicator.js +1 -1
- package/dist/tools/document-summarizer.js +2 -2
- package/dist/tools/memory/store-memory.d.ts +1 -1
- package/dist/tools/memory/store-memory.js +2 -2
- package/dist/tools/ticket-tools.d.ts +2 -2
- package/dist/tools/ticket-tools.js +3 -3
- package/dist/tools/web/duck-duck-go.d.ts +3 -3
- package/dist/tools/web/duck-duck-go.js +4 -4
- package/dist/tools/web/exa.d.ts +1 -1
- package/dist/tools/web/exa.js +1 -1
- package/dist/tools/web/scraper.js +1 -1
- package/dist/tools/web/tavily.d.ts +2 -2
- package/dist/tools/web/tavily.js +2 -2
- package/dist/tools/web/types.d.ts +2 -2
- package/dist/tools/web/types.js +2 -2
- package/package.json +23 -17
- package/LICENSE.commercial +0 -111
- package/dist/ingestion/cms-indexer.d.ts.map +0 -1
- package/dist/llm/providers/anthropic.d.ts +0 -31
- package/dist/llm/providers/anthropic.d.ts.map +0 -1
- package/dist/llm/providers/anthropic.js +0 -264
- package/dist/llm/providers/bitnet.d.ts +0 -28
- package/dist/llm/providers/bitnet.d.ts.map +0 -1
- package/dist/llm/providers/bitnet.js +0 -36
- package/dist/llm/providers/openai.d.ts.map +0 -1
- package/dist/tools/cms/collection-tools.d.ts.map +0 -1
- package/dist/tools/cms/factory.d.ts.map +0 -1
- package/dist/tools/cms/global-tools.d.ts.map +0 -1
- package/dist/tools/cms/index.d.ts.map +0 -1
- package/dist/tools/cms/media-tools.d.ts.map +0 -1
- package/dist/tools/cms/user-tools.d.ts.map +0 -1
package/dist/skills/types.d.ts
CHANGED
|
@@ -27,13 +27,13 @@ export declare const SkillMetadataSchema: z.ZodObject<{
|
|
|
27
27
|
repository: z.ZodOptional<z.ZodString>;
|
|
28
28
|
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
29
29
|
compatibility: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
30
|
-
openai: "openai";
|
|
31
|
-
anthropic: "anthropic";
|
|
32
30
|
"claude-code": "claude-code";
|
|
33
31
|
cursor: "cursor";
|
|
34
32
|
windsurf: "windsurf";
|
|
35
33
|
cline: "cline";
|
|
36
34
|
copilot: "copilot";
|
|
35
|
+
openai: "openai";
|
|
36
|
+
anthropic: "anthropic";
|
|
37
37
|
universal: "universal";
|
|
38
38
|
}>>>;
|
|
39
39
|
allowedTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
@@ -78,13 +78,13 @@ export declare const SkillSchema: z.ZodObject<{
|
|
|
78
78
|
repository: z.ZodOptional<z.ZodString>;
|
|
79
79
|
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
80
80
|
compatibility: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
81
|
-
openai: "openai";
|
|
82
|
-
anthropic: "anthropic";
|
|
83
81
|
"claude-code": "claude-code";
|
|
84
82
|
cursor: "cursor";
|
|
85
83
|
windsurf: "windsurf";
|
|
86
84
|
cline: "cline";
|
|
87
85
|
copilot: "copilot";
|
|
86
|
+
openai: "openai";
|
|
87
|
+
anthropic: "anthropic";
|
|
88
88
|
universal: "universal";
|
|
89
89
|
}>>>;
|
|
90
90
|
allowedTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
@@ -143,13 +143,13 @@ export declare const SkillActivationResultSchema: z.ZodObject<{
|
|
|
143
143
|
repository: z.ZodOptional<z.ZodString>;
|
|
144
144
|
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
145
145
|
compatibility: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
146
|
-
openai: "openai";
|
|
147
|
-
anthropic: "anthropic";
|
|
148
146
|
"claude-code": "claude-code";
|
|
149
147
|
cursor: "cursor";
|
|
150
148
|
windsurf: "windsurf";
|
|
151
149
|
cline: "cline";
|
|
152
150
|
copilot: "copilot";
|
|
151
|
+
openai: "openai";
|
|
152
|
+
anthropic: "anthropic";
|
|
153
153
|
universal: "universal";
|
|
154
154
|
}>>>;
|
|
155
155
|
allowedTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
@@ -83,7 +83,7 @@ export const PromptSpecSchema = z.object({
|
|
|
83
83
|
guardrails: PromptGuardrailsSchema,
|
|
84
84
|
/** Security constraints */
|
|
85
85
|
security: PromptSecuritySchema,
|
|
86
|
-
/** Examples
|
|
86
|
+
/** Examples - at least one required for documentation and testing */
|
|
87
87
|
examples: z.array(PromptExampleSchema).min(1, 'At least one example is required'),
|
|
88
88
|
/** Who created this prompt */
|
|
89
89
|
author: z.string().min(1),
|
|
@@ -66,7 +66,7 @@ export const SkillSpecSchema = z.object({
|
|
|
66
66
|
permissions: SkillPermissionsSchema,
|
|
67
67
|
/** Security constraints */
|
|
68
68
|
security: SkillSecuritySchema,
|
|
69
|
-
/** Test cases
|
|
69
|
+
/** Test cases - at least one required */
|
|
70
70
|
testCases: z.array(SkillTestCaseSchema).min(1, 'At least one test case is required'),
|
|
71
71
|
/** Who created this skill */
|
|
72
72
|
author: z.string().min(1),
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Admin Collection Tools
|
|
3
3
|
* Tools for managing collection documents (create, read, update, delete)
|
|
4
4
|
*/
|
|
5
5
|
import type { Tool } from '../base.js';
|
|
6
6
|
/**
|
|
7
7
|
* Tool: List all collections
|
|
8
|
-
* Returns available collections in the
|
|
8
|
+
* Returns available collections in the admin
|
|
9
9
|
*/
|
|
10
10
|
export declare const listCollectionsTool: Tool;
|
|
11
11
|
/**
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collection-tools.d.ts","sourceRoot":"","sources":["../../../src/tools/admin/collection-tools.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,IAAI,EAAc,MAAM,YAAY,CAAC;AAEnD;;;GAGG;AACH,eAAO,MAAM,mBAAmB,EAAE,IAiCjC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,IA2C/B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,eAAe,EAAE,IAwB7B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,IA+BhC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,IAmChC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,IAwBhC,CAAC"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Admin Collection Tools
|
|
3
3
|
* Tools for managing collection documents (create, read, update, delete)
|
|
4
4
|
*/
|
|
5
5
|
import { z } from 'zod/v4';
|
|
6
6
|
/**
|
|
7
7
|
* Tool: List all collections
|
|
8
|
-
* Returns available collections in the
|
|
8
|
+
* Returns available collections in the admin
|
|
9
9
|
*/
|
|
10
10
|
export const listCollectionsTool = {
|
|
11
11
|
name: 'list_collections',
|
|
12
|
-
description: 'Get a list of all available
|
|
12
|
+
description: 'Get a list of all available admin collections. Use this to discover what content types exist (e.g., pages, posts, users, media).',
|
|
13
13
|
parameters: z.object({}),
|
|
14
14
|
async execute() {
|
|
15
15
|
try {
|
|
@@ -45,7 +45,7 @@ export const listCollectionsTool = {
|
|
|
45
45
|
*/
|
|
46
46
|
export const findDocumentsTool = {
|
|
47
47
|
name: 'find_documents',
|
|
48
|
-
description: 'Search for documents in
|
|
48
|
+
description: 'Search for documents in an admin collection. Use this to find existing content before creating or updating.',
|
|
49
49
|
parameters: z.object({
|
|
50
50
|
collection: z.string().describe('The collection slug (e.g., "pages", "posts", "users")'),
|
|
51
51
|
page: z.number().optional().describe('Page number for pagination (default: 1)'),
|
|
@@ -77,7 +77,7 @@ export const findDocumentsTool = {
|
|
|
77
77
|
*/
|
|
78
78
|
export const getDocumentTool = {
|
|
79
79
|
name: 'get_document',
|
|
80
|
-
description: 'Get a specific document by ID from
|
|
80
|
+
description: 'Get a specific document by ID from an admin collection. Use this to retrieve full details of a single item.',
|
|
81
81
|
parameters: z.object({
|
|
82
82
|
collection: z.string().describe('The collection slug (e.g., "pages", "posts")'),
|
|
83
83
|
id: z.string().describe('The document ID'),
|
|
@@ -102,7 +102,7 @@ export const getDocumentTool = {
|
|
|
102
102
|
*/
|
|
103
103
|
export const createDocumentTool = {
|
|
104
104
|
name: 'create_document',
|
|
105
|
-
description: 'Create a new document in
|
|
105
|
+
description: 'Create a new document in an admin collection. Use this to add new content like pages, posts, or other records.',
|
|
106
106
|
parameters: z.object({
|
|
107
107
|
collection: z.string().describe('The collection slug (e.g., "pages", "posts")'),
|
|
108
108
|
data: z
|
|
@@ -129,7 +129,7 @@ export const createDocumentTool = {
|
|
|
129
129
|
*/
|
|
130
130
|
export const updateDocumentTool = {
|
|
131
131
|
name: 'update_document',
|
|
132
|
-
description: 'Update an existing document in
|
|
132
|
+
description: 'Update an existing document in an admin collection. Use this to modify content like changing titles, updating text, etc.',
|
|
133
133
|
parameters: z.object({
|
|
134
134
|
collection: z.string().describe('The collection slug (e.g., "pages", "posts")'),
|
|
135
135
|
id: z.string().describe('The document ID to update'),
|
|
@@ -157,7 +157,7 @@ export const updateDocumentTool = {
|
|
|
157
157
|
*/
|
|
158
158
|
export const deleteDocumentTool = {
|
|
159
159
|
name: 'delete_document',
|
|
160
|
-
description: 'Delete a document from
|
|
160
|
+
description: 'Delete a document from an admin collection. Use this to remove unwanted content. This action is permanent.',
|
|
161
161
|
parameters: z.object({
|
|
162
162
|
collection: z.string().describe('The collection slug (e.g., "pages", "posts")'),
|
|
163
163
|
id: z.string().describe('The document ID to delete'),
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* Creates
|
|
2
|
+
* admin Tools Factory
|
|
3
|
+
* Creates admin tools with API client injected for actual execution
|
|
4
4
|
*/
|
|
5
5
|
import type { Tool } from '../base.js';
|
|
6
6
|
/**
|
|
7
7
|
* API Client interface (compatible with @revealui/core/admin/utils/apiClient)
|
|
8
8
|
*/
|
|
9
|
-
export interface
|
|
9
|
+
export interface AdminAPIClient {
|
|
10
10
|
find(options: {
|
|
11
11
|
collection: string;
|
|
12
12
|
page?: number;
|
|
@@ -43,7 +43,7 @@ export interface CMSAPIClient {
|
|
|
43
43
|
}): Promise<unknown>;
|
|
44
44
|
}
|
|
45
45
|
/**
|
|
46
|
-
* Collection metadata for
|
|
46
|
+
* Collection metadata for admin tools
|
|
47
47
|
* Simplified representation of a collection configuration
|
|
48
48
|
*/
|
|
49
49
|
export interface CollectionMetadata {
|
|
@@ -52,7 +52,7 @@ export interface CollectionMetadata {
|
|
|
52
52
|
description?: string;
|
|
53
53
|
}
|
|
54
54
|
/**
|
|
55
|
-
* Global metadata for
|
|
55
|
+
* Global metadata for admin tools
|
|
56
56
|
* Simplified representation of a global configuration
|
|
57
57
|
*/
|
|
58
58
|
export interface GlobalMetadata {
|
|
@@ -61,7 +61,7 @@ export interface GlobalMetadata {
|
|
|
61
61
|
description?: string;
|
|
62
62
|
}
|
|
63
63
|
/**
|
|
64
|
-
* User context for
|
|
64
|
+
* User context for admin tools
|
|
65
65
|
*/
|
|
66
66
|
export interface UserContext {
|
|
67
67
|
id: string;
|
|
@@ -69,11 +69,11 @@ export interface UserContext {
|
|
|
69
69
|
role?: string;
|
|
70
70
|
}
|
|
71
71
|
/**
|
|
72
|
-
* Configuration interface for
|
|
72
|
+
* Configuration interface for admin tools
|
|
73
73
|
*/
|
|
74
|
-
export interface
|
|
74
|
+
export interface AdminToolsConfig {
|
|
75
75
|
/** API client instance */
|
|
76
|
-
apiClient:
|
|
76
|
+
apiClient: AdminAPIClient;
|
|
77
77
|
/** Available collections (optional, for list_collections tool) */
|
|
78
78
|
collections?: CollectionMetadata[];
|
|
79
79
|
/** Available globals (optional, for list_globals tool) */
|
|
@@ -82,8 +82,8 @@ export interface CMSToolsConfig {
|
|
|
82
82
|
user?: UserContext;
|
|
83
83
|
}
|
|
84
84
|
/**
|
|
85
|
-
* Create
|
|
85
|
+
* Create admin tools with API client injected
|
|
86
86
|
* This factory function creates functional tools by injecting the actual API implementation
|
|
87
87
|
*/
|
|
88
|
-
export declare function
|
|
88
|
+
export declare function createAdminTools(config: AdminToolsConfig): Tool[];
|
|
89
89
|
//# sourceMappingURL=factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../src/tools/admin/factory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAyBvC;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,CAAC,OAAO,EAAE;QACZ,UAAU,EAAE,MAAM,CAAC;QACnB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAChC,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,GAAG,OAAO,CAAC;QACV,IAAI,CAAC,EAAE,OAAO,EAAE,CAAC;QACjB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC,CAAC;IAEH,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAE3D,MAAM,CAAC,OAAO,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAEzF,MAAM,CAAC,OAAO,EAAE;QACd,UAAU,EAAE,MAAM,CAAC;QACnB,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KAC/B,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAErB,MAAM,CAAC,OAAO,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEnE,UAAU,CAAC,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAExE,YAAY,CAAC,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC1F;AAED;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,0BAA0B;IAC1B,SAAS,EAAE,cAAc,CAAC;IAE1B,kEAAkE;IAClE,WAAW,CAAC,EAAE,kBAAkB,EAAE,CAAC;IAEnC,0DAA0D;IAC1D,OAAO,CAAC,EAAE,cAAc,EAAE,CAAC;IAE3B,mDAAmD;IACnD,IAAI,CAAC,EAAE,WAAW,CAAC;CACpB;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,GAAG,IAAI,EAAE,CAggBjE"}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* Creates
|
|
2
|
+
* admin Tools Factory
|
|
3
|
+
* Creates admin tools with API client injected for actual execution
|
|
4
4
|
*/
|
|
5
5
|
import { createDocumentTool, deleteDocumentTool, findDocumentsTool, getDocumentTool, listCollectionsTool, updateDocumentTool, } from './collection-tools.js';
|
|
6
6
|
import { getGlobalTool, listGlobalsTool, updateGlobalTool } from './global-tools.js';
|
|
7
7
|
import { deleteMediaTool, getMediaTool, listMediaTool, updateMediaTool, uploadMediaTool, } from './media-tools.js';
|
|
8
8
|
import { createUserTool, deleteUserTool, getCurrentUserTool, listUsersTool, updateUserTool, } from './user-tools.js';
|
|
9
9
|
/**
|
|
10
|
-
* Create
|
|
10
|
+
* Create admin tools with API client injected
|
|
11
11
|
* This factory function creates functional tools by injecting the actual API implementation
|
|
12
12
|
*/
|
|
13
|
-
export function
|
|
13
|
+
export function createAdminTools(config) {
|
|
14
14
|
const { apiClient, collections, globals, user } = config;
|
|
15
15
|
// Clone tools and inject API client implementation
|
|
16
16
|
const tools = [];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"global-tools.d.ts","sourceRoot":"","sources":["../../../src/tools/admin/global-tools.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,IAAI,EAAc,MAAM,YAAY,CAAC;AAEnD;;;GAGG;AACH,eAAO,MAAM,eAAe,EAAE,IA6B7B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,aAAa,EAAE,IAwB3B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,IA+B9B,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Admin Global Tools
|
|
3
3
|
* Tools for managing global content (Header, Footer, Settings)
|
|
4
4
|
*/
|
|
5
5
|
import { z } from 'zod/v4';
|
|
@@ -9,7 +9,7 @@ import { z } from 'zod/v4';
|
|
|
9
9
|
*/
|
|
10
10
|
export const listGlobalsTool = {
|
|
11
11
|
name: 'list_globals',
|
|
12
|
-
description: 'Get a list of all available
|
|
12
|
+
description: 'Get a list of all available admin globals. Globals are site-wide settings like Header, Footer, and Settings.',
|
|
13
13
|
parameters: z.object({}),
|
|
14
14
|
async execute() {
|
|
15
15
|
try {
|
|
@@ -41,7 +41,7 @@ export const listGlobalsTool = {
|
|
|
41
41
|
*/
|
|
42
42
|
export const getGlobalTool = {
|
|
43
43
|
name: 'get_global',
|
|
44
|
-
description: 'Get the current configuration of a
|
|
44
|
+
description: 'Get the current configuration of a admin global. Use this to see the current state before updating (e.g., current header navigation items).',
|
|
45
45
|
parameters: z.object({
|
|
46
46
|
slug: z.string().describe('The global slug (e.g., "header", "footer", "settings")'),
|
|
47
47
|
depth: z.number().optional().describe('Depth of populated relationships (default: 0, max: 10)'),
|
|
@@ -66,7 +66,7 @@ export const getGlobalTool = {
|
|
|
66
66
|
*/
|
|
67
67
|
export const updateGlobalTool = {
|
|
68
68
|
name: 'update_global',
|
|
69
|
-
description: 'Update a
|
|
69
|
+
description: 'Update a admin global configuration. Use this to modify site-wide settings like header navigation, footer links, or global settings. Common uses:\n- Add/remove navigation links in header\n- Update footer content\n- Change site-wide settings\n\nExample for header navigation:\n{\n "slug": "header",\n "data": {\n "navItems": [\n {"link": {"type": "custom", "label": "Home", "url": "/"}},\n {"link": {"type": "custom", "label": "About", "url": "/about"}}\n ]\n }\n}',
|
|
70
70
|
parameters: z.object({
|
|
71
71
|
slug: z.string().describe('The global slug (e.g., "header", "footer", "settings")'),
|
|
72
72
|
data: z
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* Complete set of tools for AI-powered
|
|
2
|
+
* admin Tools Package
|
|
3
|
+
* Complete set of tools for AI-powered admin management
|
|
4
4
|
*/
|
|
5
5
|
export { createDocumentTool, deleteDocumentTool, findDocumentsTool, getDocumentTool, listCollectionsTool, updateDocumentTool, } from './collection-tools.js';
|
|
6
|
-
export type {
|
|
7
|
-
export {
|
|
6
|
+
export type { AdminAPIClient, AdminToolsConfig, CollectionMetadata, GlobalMetadata, UserContext, } from './factory.js';
|
|
7
|
+
export { createAdminTools } from './factory.js';
|
|
8
8
|
export { getGlobalTool, listGlobalsTool, updateGlobalTool } from './global-tools.js';
|
|
9
9
|
export { deleteMediaTool, getMediaTool, listMediaTool, updateMediaTool, uploadMediaTool, } from './media-tools.js';
|
|
10
10
|
export { createUserTool, deleteUserTool, getCurrentUserTool, listUsersTool, updateUserTool, } from './user-tools.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/admin/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EACV,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,EACd,WAAW,GACZ,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErF,OAAO,EACL,eAAe,EACf,YAAY,EACZ,aAAa,EACb,eAAe,EACf,eAAe,GAChB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,aAAa,EACb,cAAc,GACf,MAAM,iBAAiB,CAAC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* Complete set of tools for AI-powered
|
|
2
|
+
* admin Tools Package
|
|
3
|
+
* Complete set of tools for AI-powered admin management
|
|
4
4
|
*/
|
|
5
5
|
// Export individual tool definitions (for documentation/reference)
|
|
6
6
|
export { createDocumentTool, deleteDocumentTool, findDocumentsTool, getDocumentTool, listCollectionsTool, updateDocumentTool, } from './collection-tools.js';
|
|
7
7
|
// Export factory for creating functional tools
|
|
8
|
-
export {
|
|
8
|
+
export { createAdminTools } from './factory.js';
|
|
9
9
|
export { getGlobalTool, listGlobalsTool, updateGlobalTool } from './global-tools.js';
|
|
10
10
|
export { deleteMediaTool, getMediaTool, listMediaTool, updateMediaTool, uploadMediaTool, } from './media-tools.js';
|
|
11
11
|
export { createUserTool, deleteUserTool, getCurrentUserTool, listUsersTool, updateUserTool, } from './user-tools.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"media-tools.d.ts","sourceRoot":"","sources":["../../../src/tools/admin/media-tools.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,IAAI,EAAc,MAAM,YAAY,CAAC;AAEnD;;;GAGG;AACH,eAAO,MAAM,aAAa,EAAE,IAqC3B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,YAAY,EAAE,IAsB1B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,eAAe,EAAE,IAyC7B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,eAAe,EAAE,IAuB7B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,eAAe,EAAE,IAoC7B,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Admin Media Tools
|
|
3
3
|
* Tools for managing media files (images, videos, documents)
|
|
4
4
|
*/
|
|
5
5
|
import { z } from 'zod/v4';
|
|
@@ -9,7 +9,7 @@ import { z } from 'zod/v4';
|
|
|
9
9
|
*/
|
|
10
10
|
export const listMediaTool = {
|
|
11
11
|
name: 'list_media',
|
|
12
|
-
description: 'Get a list of media files from the
|
|
12
|
+
description: 'Get a list of media files from the admin media library. Use this to browse uploaded images, videos, and documents.',
|
|
13
13
|
parameters: z.object({
|
|
14
14
|
page: z.number().optional().describe('Page number for pagination (default: 1)'),
|
|
15
15
|
limit: z.number().optional().describe('Number of results per page (default: 10)'),
|
|
@@ -63,7 +63,7 @@ export const getMediaTool = {
|
|
|
63
63
|
*/
|
|
64
64
|
export const uploadMediaTool = {
|
|
65
65
|
name: 'upload_media',
|
|
66
|
-
description: 'Upload a new media file (image, video, or document) to the
|
|
66
|
+
description: 'Upload a new media file (image, video, or document) to the admin. The file should be provided as a base64-encoded string.',
|
|
67
67
|
parameters: z.object({
|
|
68
68
|
filename: z.string().describe('The filename (e.g., "logo.png")'),
|
|
69
69
|
mimeType: z.string().describe('The MIME type (e.g., "image/png", "image/jpeg")'),
|
|
@@ -93,7 +93,7 @@ export const uploadMediaTool = {
|
|
|
93
93
|
*/
|
|
94
94
|
export const deleteMediaTool = {
|
|
95
95
|
name: 'delete_media',
|
|
96
|
-
description: 'Delete a media file from the
|
|
96
|
+
description: 'Delete a media file from the admin media library. This removes both the database record and the file from storage. This action is permanent.',
|
|
97
97
|
parameters: z.object({
|
|
98
98
|
id: z.string().describe('The media file ID to delete'),
|
|
99
99
|
}),
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user-tools.d.ts","sourceRoot":"","sources":["../../../src/tools/admin/user-tools.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,IAAI,EAAc,MAAM,YAAY,CAAC;AAEnD;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,IAoBhC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,aAAa,EAAE,IAiC3B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,IAsC5B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,IAsC5B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,IAuB5B,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* file_edit
|
|
2
|
+
* file_edit - Surgical string replacement in a file
|
|
3
3
|
*/
|
|
4
4
|
import { readFileSync, writeFileSync } from 'node:fs';
|
|
5
5
|
import { z } from 'zod/v4';
|
|
@@ -23,7 +23,7 @@ export const fileEditTool = {
|
|
|
23
23
|
return { success: false, error: check.reason };
|
|
24
24
|
}
|
|
25
25
|
if (old_text === new_text) {
|
|
26
|
-
return { success: false, error: 'old_text and new_text are identical
|
|
26
|
+
return { success: false, error: 'old_text and new_text are identical - nothing to change' };
|
|
27
27
|
}
|
|
28
28
|
const resolvedPath = resolveSafePath(path, config);
|
|
29
29
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-glob.d.ts","sourceRoot":"","sources":["../../../src/tools/coding/file-glob.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,OAAO,KAAK,EAAE,IAAI,EAAc,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"file-glob.d.ts","sourceRoot":"","sources":["../../../src/tools/coding/file-glob.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,OAAO,KAAK,EAAE,IAAI,EAAc,MAAM,YAAY,CAAC;AAgEnD,eAAO,MAAM,YAAY,EAAE,IAgE1B,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* file_glob
|
|
2
|
+
* file_glob - Fast file pattern matching with picomatch-style globs
|
|
3
3
|
*/
|
|
4
4
|
import { readdirSync, statSync } from 'node:fs';
|
|
5
5
|
import { join, relative } from 'node:path';
|
|
@@ -8,6 +8,7 @@ import { getSafetyConfig } from './safety.js';
|
|
|
8
8
|
/** Simple glob matcher supporting *, **, and ? */
|
|
9
9
|
function matchGlob(pattern, filePath) {
|
|
10
10
|
const regex = pattern
|
|
11
|
+
.replace(/\\/g, '\\\\')
|
|
11
12
|
.replace(/\./g, '\\.')
|
|
12
13
|
.replace(/\*\*/g, '⟨GLOBSTAR⟩')
|
|
13
14
|
.replace(/\*/g, '[^/]*')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-grep.d.ts","sourceRoot":"","sources":["../../../src/tools/coding/file-grep.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,OAAO,KAAK,EAAE,IAAI,EAAc,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"file-grep.d.ts","sourceRoot":"","sources":["../../../src/tools/coding/file-grep.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,OAAO,KAAK,EAAE,IAAI,EAAc,MAAM,YAAY,CAAC;AAkGnD,eAAO,MAAM,YAAY,EAAE,IA0H1B,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* file_grep
|
|
2
|
+
* file_grep - Regex content search across files
|
|
3
3
|
*/
|
|
4
4
|
import { readdirSync, readFileSync, statSync } from 'node:fs';
|
|
5
5
|
import { join, relative } from 'node:path';
|
|
@@ -8,6 +8,7 @@ import { getSafetyConfig } from './safety.js';
|
|
|
8
8
|
/** Simple glob test for file filtering */
|
|
9
9
|
function matchesGlob(filePath, glob) {
|
|
10
10
|
const regex = glob
|
|
11
|
+
.replace(/\\/g, '\\\\')
|
|
11
12
|
.replace(/\./g, '\\.')
|
|
12
13
|
.replace(/\*\*/g, '⟨GLOBSTAR⟩')
|
|
13
14
|
.replace(/\*/g, '[^/]*')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-read.d.ts","sourceRoot":"","sources":["../../../src/tools/coding/file-read.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,IAAI,EAAc,MAAM,YAAY,CAAC;AAGnD,eAAO,MAAM,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"file-read.d.ts","sourceRoot":"","sources":["../../../src/tools/coding/file-read.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,IAAI,EAAc,MAAM,YAAY,CAAC;AAGnD,eAAO,MAAM,YAAY,EAAE,IAsE1B,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* file_read
|
|
2
|
+
* file_read - Read file contents with line numbers
|
|
3
3
|
*/
|
|
4
|
-
import { readFileSync
|
|
4
|
+
import { readFileSync } from 'node:fs';
|
|
5
5
|
import { z } from 'zod/v4';
|
|
6
6
|
import { getSafetyConfig, resolveSafePath, validatePath } from './safety.js';
|
|
7
7
|
export const fileReadTool = {
|
|
@@ -24,14 +24,20 @@ export const fileReadTool = {
|
|
|
24
24
|
const maxLines = limit ?? 2000;
|
|
25
25
|
const startLine = (offset ?? 1) - 1; // Convert to 0-based
|
|
26
26
|
try {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
// Read first, then check if directory (avoids TOCTOU race between stat and read)
|
|
28
|
+
let raw;
|
|
29
|
+
try {
|
|
30
|
+
raw = readFileSync(resolvedPath, 'utf8');
|
|
31
|
+
}
|
|
32
|
+
catch (readErr) {
|
|
33
|
+
if (readErr.code === 'EISDIR') {
|
|
34
|
+
return {
|
|
35
|
+
success: false,
|
|
36
|
+
error: `${path} is a directory, not a file. Use file_glob to list directory contents.`,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
throw readErr;
|
|
33
40
|
}
|
|
34
|
-
const raw = readFileSync(resolvedPath, 'utf8');
|
|
35
41
|
const allLines = raw.split('\n');
|
|
36
42
|
const totalLines = allLines.length;
|
|
37
43
|
const sliced = allLines.slice(startLine, startLine + maxLines);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git-ops.d.ts","sourceRoot":"","sources":["../../../src/tools/coding/git-ops.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,IAAI,EAAc,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"git-ops.d.ts","sourceRoot":"","sources":["../../../src/tools/coding/git-ops.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,IAAI,EAAc,MAAM,YAAY,CAAC;AAuBnD,eAAO,MAAM,UAAU,EAAE,IA4FxB,CAAC"}
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* git_ops
|
|
2
|
+
* git_ops - Git operations wrapper (status, diff, log, blame)
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import { execFileSync } from 'node:child_process';
|
|
5
5
|
import { z } from 'zod/v4';
|
|
6
6
|
import { getSafetyConfig } from './safety.js';
|
|
7
7
|
const GIT_OPERATIONS = ['status', 'diff', 'diff_full', 'log', 'blame', 'show', 'branch'];
|
|
8
8
|
/** Max output per git command */
|
|
9
9
|
const MAX_OUTPUT = 50_000;
|
|
10
10
|
function runGit(args, cwd) {
|
|
11
|
-
|
|
12
|
-
return execSync(cmd, {
|
|
11
|
+
return execFileSync('git', args, {
|
|
13
12
|
cwd,
|
|
14
13
|
timeout: 15_000,
|
|
15
14
|
maxBuffer: MAX_OUTPUT,
|
|
@@ -17,7 +16,6 @@ function runGit(args, cwd) {
|
|
|
17
16
|
env: {
|
|
18
17
|
...process.env,
|
|
19
18
|
GIT_TERMINAL_PROMPT: '0',
|
|
20
|
-
// Prevent pager from blocking
|
|
21
19
|
GIT_PAGER: 'cat',
|
|
22
20
|
},
|
|
23
21
|
}).trim();
|
|
@@ -25,7 +23,7 @@ function runGit(args, cwd) {
|
|
|
25
23
|
export const gitOpsTool = {
|
|
26
24
|
name: 'git_ops',
|
|
27
25
|
label: 'Git Operations',
|
|
28
|
-
description: 'Run read-only git operations: status, diff (summary), diff_full (full patch), log, blame, show, branch. Safe operations only
|
|
26
|
+
description: 'Run read-only git operations: status, diff (summary), diff_full (full patch), log, blame, show, branch. Safe operations only - no push, commit, reset, or checkout.',
|
|
29
27
|
parameters: z.object({
|
|
30
28
|
operation: z.enum(GIT_OPERATIONS).describe('Git operation to perform'),
|
|
31
29
|
args: z
|
|
@@ -57,7 +55,7 @@ export const gitOpsTool = {
|
|
|
57
55
|
output = runGit(['diff', '--stat', ...args], config.projectRoot);
|
|
58
56
|
break;
|
|
59
57
|
case 'diff_full':
|
|
60
|
-
// Full patch content for code review
|
|
58
|
+
// Full patch content for code review - hunks per file
|
|
61
59
|
output = runGit(['diff', '--no-color', '-U3', ...args], config.projectRoot);
|
|
62
60
|
break;
|
|
63
61
|
case 'log':
|
|
@@ -20,7 +20,7 @@ export { testRunnerTool } from './test-runner.js';
|
|
|
20
20
|
* Configuration for the coding tools factory
|
|
21
21
|
*/
|
|
22
22
|
export interface CodingToolsConfig {
|
|
23
|
-
/** Project root directory
|
|
23
|
+
/** Project root directory - all file operations sandboxed here */
|
|
24
24
|
projectRoot: string;
|
|
25
25
|
/** Additional directories to allow (e.g., /tmp for scratch files) */
|
|
26
26
|
allowedPaths?: string[];
|