@revealui/ai 0.2.8 → 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/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/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/client.d.ts +7 -10
- package/dist/llm/client.d.ts.map +1 -1
- package/dist/llm/client.js +10 -34
- 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 +2 -2
- 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 +4 -4
- 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 +1 -1
- package/dist/llm/providers/openai-compat.d.ts +2 -2
- package/dist/llm/providers/openai-compat.js +5 -5
- package/dist/llm/providers/vultr.js +1 -1
- package/dist/llm/server.d.ts +0 -1
- package/dist/llm/server.d.ts.map +1 -1
- package/dist/llm/server.js +0 -1
- 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/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 +20 -15
- package/dist/ingestion/cms-indexer.d.ts.map +0 -1
- 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/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
|
@@ -92,11 +92,11 @@ export class AgentOrchestrator {
|
|
|
92
92
|
* Find the best agent for a task.
|
|
93
93
|
*
|
|
94
94
|
* Routing priority:
|
|
95
|
-
* 1. Capability intersection
|
|
95
|
+
* 1. Capability intersection - agent whose AgentConfig.capabilities overlaps
|
|
96
96
|
* with task.requiredCapabilities (highest-overlap agent wins)
|
|
97
|
-
* 2. Tool-name substring match
|
|
97
|
+
* 2. Tool-name substring match - agent has a tool whose name includes the
|
|
98
98
|
* task type string (legacy fallback)
|
|
99
|
-
* 3. First registered agent
|
|
99
|
+
* 3. First registered agent - last-resort fallback
|
|
100
100
|
*/
|
|
101
101
|
findBestAgent(task) {
|
|
102
102
|
// 1. Capability-based routing
|
|
@@ -10,7 +10,7 @@ import type { MCPToolSource } from '../tools/mcp-adapter.js';
|
|
|
10
10
|
import type { Agent, AgentResult, Task } from './agent.js';
|
|
11
11
|
/**
|
|
12
12
|
* Controls how much of the model's token budget is allocated to internal reasoning.
|
|
13
|
-
* Applies to Anthropic Claude only
|
|
13
|
+
* Applies to Anthropic Claude only - ignored by other providers.
|
|
14
14
|
*
|
|
15
15
|
* | Level | Budget (tokens) | Use case |
|
|
16
16
|
* |---------|-----------------|-----------------------------------|
|
|
@@ -176,7 +176,7 @@ export class AgentRuntime {
|
|
|
176
176
|
const needsApproval = tool.requiresApproval || this.config.alwaysRequireApproval?.includes(tool.name);
|
|
177
177
|
if (needsApproval) {
|
|
178
178
|
if (!this.config.approvalCallback) {
|
|
179
|
-
// No approval callback
|
|
179
|
+
// No approval callback - deny by default
|
|
180
180
|
const denied = {
|
|
181
181
|
success: false,
|
|
182
182
|
error: `Tool "${tool.label ?? tool.name}" requires human approval but no approval handler is configured.`,
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Each yielded AgentStreamChunk maps to one SSE event.
|
|
6
6
|
*
|
|
7
7
|
* AnythingLLM lesson: SSE is the correct approach for unidirectional LLM output.
|
|
8
|
-
* EventSource is not used client-side because it doesn't support POST
|
|
8
|
+
* EventSource is not used client-side because it doesn't support POST - use fetch + ReadableStream.
|
|
9
9
|
*/
|
|
10
10
|
import type { LLMClient } from '../llm/client.js';
|
|
11
11
|
import type { ToolResult } from '../tools/base.js';
|
|
@@ -29,7 +29,7 @@ export declare class StreamingAgentRuntime extends AgentRuntime {
|
|
|
29
29
|
constructor(config?: RuntimeConfig);
|
|
30
30
|
/**
|
|
31
31
|
* Stream a task execution, yielding typed events as they occur.
|
|
32
|
-
* Accepts an AbortSignal
|
|
32
|
+
* Accepts an AbortSignal - on abort, emits an error event and stops.
|
|
33
33
|
*/
|
|
34
34
|
streamTask(agent: Agent, task: Task, llmClient: LLMClient, signal?: AbortSignal): AsyncGenerator<AgentStreamChunk>;
|
|
35
35
|
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Each yielded AgentStreamChunk maps to one SSE event.
|
|
6
6
|
*
|
|
7
7
|
* AnythingLLM lesson: SSE is the correct approach for unidirectional LLM output.
|
|
8
|
-
* EventSource is not used client-side because it doesn't support POST
|
|
8
|
+
* EventSource is not used client-side because it doesn't support POST - use fetch + ReadableStream.
|
|
9
9
|
*/
|
|
10
10
|
import { z } from 'zod/v4';
|
|
11
11
|
import { compressToolResult } from '../inference/tool-result-compressor.js';
|
|
@@ -17,7 +17,7 @@ export class StreamingAgentRuntime extends AgentRuntime {
|
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
19
|
* Stream a task execution, yielding typed events as they occur.
|
|
20
|
-
* Accepts an AbortSignal
|
|
20
|
+
* Accepts an AbortSignal - on abort, emits an error event and stops.
|
|
21
21
|
*/
|
|
22
22
|
async *streamTask(agent, task, llmClient, signal) {
|
|
23
23
|
const startTime = Date.now();
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* Closes the loop between the ticketing system and the AI agent system.
|
|
5
5
|
*
|
|
6
6
|
* Flow:
|
|
7
|
-
* Ticket (title + description) → Task → Agent (
|
|
8
|
-
* → agentic loop →
|
|
7
|
+
* Ticket (title + description) → Task → Agent (admin tools + ticket tools)
|
|
8
|
+
* → agentic loop → admin mutations + ticket status updated + comment written
|
|
9
9
|
*
|
|
10
10
|
* Usage:
|
|
11
11
|
* const dispatcher = new TicketAgentDispatcher({ llmClient, apiClient, ticketClient })
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
import type { Database } from '@revealui/db/client';
|
|
15
15
|
import type { LLMClient } from '../llm/client.js';
|
|
16
16
|
import type { EpisodicMemory } from '../memory/stores/episodic-memory.js';
|
|
17
|
-
import type {
|
|
17
|
+
import type { AdminAPIClient, CollectionMetadata, GlobalMetadata } from '../tools/admin/factory.js';
|
|
18
18
|
import type { TicketMutationClient } from '../tools/ticket-tools.js';
|
|
19
19
|
import type { AgentResult } from './agent.js';
|
|
20
20
|
export interface TicketInput {
|
|
@@ -28,22 +28,22 @@ export interface TicketInput {
|
|
|
28
28
|
export interface TicketAgentConfig {
|
|
29
29
|
/** LLM client (Anthropic, OpenAI, etc.) */
|
|
30
30
|
llmClient: LLMClient;
|
|
31
|
-
/**
|
|
32
|
-
apiClient:
|
|
33
|
-
/** Ticket mutation client
|
|
31
|
+
/** admin API client - used to inject into admin tools */
|
|
32
|
+
apiClient: AdminAPIClient;
|
|
33
|
+
/** Ticket mutation client - used to update status and add comments */
|
|
34
34
|
ticketClient: TicketMutationClient;
|
|
35
|
-
/** Available
|
|
35
|
+
/** Available admin collections (optional, improves tool descriptions) */
|
|
36
36
|
collections?: CollectionMetadata[];
|
|
37
|
-
/** Available
|
|
37
|
+
/** Available admin globals (optional) */
|
|
38
38
|
globals?: GlobalMetadata[];
|
|
39
39
|
/**
|
|
40
40
|
* Memory instance to share across dispatches (optional).
|
|
41
|
-
* If omitted, each dispatch uses a no-op stub
|
|
41
|
+
* If omitted, each dispatch uses a no-op stub - the runtime does not
|
|
42
42
|
* call agent.memory directly, so this is safe for stateless dispatch.
|
|
43
43
|
*/
|
|
44
44
|
memory?: EpisodicMemory;
|
|
45
45
|
/**
|
|
46
|
-
* Database client
|
|
46
|
+
* Database client - enables the document_summarize tool.
|
|
47
47
|
* If omitted, the summarizer tool is not included in the agent's toolset.
|
|
48
48
|
*/
|
|
49
49
|
db?: Database;
|
|
@@ -61,7 +61,7 @@ export declare class TicketAgentDispatcher {
|
|
|
61
61
|
*
|
|
62
62
|
* The agent will:
|
|
63
63
|
* - Receive the ticket as its task description
|
|
64
|
-
* - Have access to all
|
|
64
|
+
* - Have access to all admin tools (create/update/delete content, globals, media, users)
|
|
65
65
|
* - Have access to ticket mutation tools (update status, add comment)
|
|
66
66
|
* - Run the agentic loop until done or max iterations
|
|
67
67
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ticket-agent.d.ts","sourceRoot":"","sources":["../../src/orchestration/ticket-agent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,KAAK,EACV,
|
|
1
|
+
{"version":3,"file":"ticket-agent.d.ts","sourceRoot":"","sources":["../../src/orchestration/ticket-agent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,KAAK,EACV,cAAc,EAEd,kBAAkB,EAClB,cAAc,EACf,MAAM,2BAA2B,CAAC;AAGnC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAGrE,OAAO,KAAK,EAAS,WAAW,EAAQ,MAAM,YAAY,CAAC;AAG3D,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,0GAA0G;IAC1G,WAAW,EAAE,OAAO,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,iBAAiB;IAChC,2CAA2C;IAC3C,SAAS,EAAE,SAAS,CAAC;IAErB,2DAA2D;IAC3D,SAAS,EAAE,cAAc,CAAC;IAE1B,wEAAwE;IACxE,YAAY,EAAE,oBAAoB,CAAC;IAEnC,yEAAyE;IACzE,WAAW,CAAC,EAAE,kBAAkB,EAAE,CAAC;IAEnC,yCAAyC;IACzC,OAAO,CAAC,EAAE,cAAc,EAAE,CAAC;IAE3B;;;;OAIG;IACH,MAAM,CAAC,EAAE,cAAc,CAAC;IAExB;;;OAGG;IACH,EAAE,CAAC,EAAE,QAAQ,CAAC;IAEd,wDAAwD;IACxD,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,uCAAuC;IACvC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAwDD,qBAAa,qBAAqB;IAChC,OAAO,CAAC,MAAM,CAAoB;IAClC,OAAO,CAAC,YAAY,CAAoB;gBAE5B,MAAM,EAAE,iBAAiB;IAUrC;;;;;;;;OAQG;IACG,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;CAwD1D"}
|
|
@@ -4,14 +4,14 @@
|
|
|
4
4
|
* Closes the loop between the ticketing system and the AI agent system.
|
|
5
5
|
*
|
|
6
6
|
* Flow:
|
|
7
|
-
* Ticket (title + description) → Task → Agent (
|
|
8
|
-
* → agentic loop →
|
|
7
|
+
* Ticket (title + description) → Task → Agent (admin tools + ticket tools)
|
|
8
|
+
* → agentic loop → admin mutations + ticket status updated + comment written
|
|
9
9
|
*
|
|
10
10
|
* Usage:
|
|
11
11
|
* const dispatcher = new TicketAgentDispatcher({ llmClient, apiClient, ticketClient })
|
|
12
12
|
* const result = await dispatcher.dispatch(ticket)
|
|
13
13
|
*/
|
|
14
|
-
import {
|
|
14
|
+
import { createAdminTools } from '../tools/admin/factory.js';
|
|
15
15
|
import { createDocumentSummarizerTool } from '../tools/document-summarizer.js';
|
|
16
16
|
import { createTicketTools } from '../tools/ticket-tools.js';
|
|
17
17
|
import { webScraperTool } from '../tools/web/scraper.js';
|
|
@@ -61,7 +61,7 @@ function buildInstructions(ticket) {
|
|
|
61
61
|
|
|
62
62
|
Your job is to:
|
|
63
63
|
1. Understand the intent of the ticket
|
|
64
|
-
2. Use the available
|
|
64
|
+
2. Use the available admin tools to take the necessary actions (create, update, or delete content)
|
|
65
65
|
3. When your work is done, call add_ticket_comment to summarize what you did
|
|
66
66
|
4. Finally, call update_ticket_status with status="done"
|
|
67
67
|
5. If you cannot complete the task, call add_ticket_comment to explain why, then update_ticket_status with status="blocked"
|
|
@@ -91,21 +91,21 @@ export class TicketAgentDispatcher {
|
|
|
91
91
|
*
|
|
92
92
|
* The agent will:
|
|
93
93
|
* - Receive the ticket as its task description
|
|
94
|
-
* - Have access to all
|
|
94
|
+
* - Have access to all admin tools (create/update/delete content, globals, media, users)
|
|
95
95
|
* - Have access to ticket mutation tools (update status, add comment)
|
|
96
96
|
* - Run the agentic loop until done or max iterations
|
|
97
97
|
*/
|
|
98
98
|
async dispatch(ticket) {
|
|
99
99
|
const { apiClient, ticketClient, collections, globals, memory: sharedMemory, db } = this.config;
|
|
100
|
-
// Build tool set:
|
|
100
|
+
// Build tool set: admin tools + ticket mutation tools + web scraper + optional summarizer
|
|
101
101
|
const cmsConfig = { apiClient, collections, globals };
|
|
102
|
-
const cmsTools =
|
|
102
|
+
const cmsTools = createAdminTools(cmsConfig);
|
|
103
103
|
const ticketTools = createTicketTools(ticket.id, ticketClient);
|
|
104
104
|
const extraTools = db
|
|
105
105
|
? [webScraperTool, createDocumentSummarizerTool(db, this.config.llmClient)]
|
|
106
106
|
: [webScraperTool];
|
|
107
107
|
const tools = [...cmsTools, ...ticketTools, ...extraTools];
|
|
108
|
-
// The runtime does not call agent.memory
|
|
108
|
+
// The runtime does not call agent.memory - satisfy the interface with a stub when no
|
|
109
109
|
// shared memory instance is provided. Cast is safe: only runtime touches this field.
|
|
110
110
|
const memory = (sharedMemory ?? {});
|
|
111
111
|
const agent = {
|
|
@@ -119,7 +119,7 @@ export class TicketAgentDispatcher {
|
|
|
119
119
|
agentId: `ticket-agent-${ticket.id}`,
|
|
120
120
|
currentTask: {
|
|
121
121
|
id: ticket.id,
|
|
122
|
-
type: ticket.type ?? '
|
|
122
|
+
type: ticket.type ?? 'admin',
|
|
123
123
|
description: descriptionToString(ticket.description),
|
|
124
124
|
},
|
|
125
125
|
};
|
|
@@ -133,7 +133,7 @@ export class TicketAgentDispatcher {
|
|
|
133
133
|
: ticket.title;
|
|
134
134
|
const task = {
|
|
135
135
|
id: ticket.id,
|
|
136
|
-
type: ticket.type ?? '
|
|
136
|
+
type: ticket.type ?? 'admin',
|
|
137
137
|
description: taskDescription,
|
|
138
138
|
priority: ticket.priority === 'critical' ? 1 : ticket.priority === 'high' ? 2 : 3,
|
|
139
139
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vercel-catalog.d.ts","sourceRoot":"","sources":["../../../src/skills/catalog/vercel-catalog.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,OAAO,KAAK,EAAmB,aAAa,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE7F;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,mDAAmD;IACnD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,oDAAoD;IACpD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,2CAA2C;IAC3C,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAiBD;;;;;;;;GAQG;AACH,wBAAsB,kBAAkB,CAAC,MAAM,GAAE,aAAkB,GAAG,OAAO,CAAC,aAAa,CAAC,CAgC3F;
|
|
1
|
+
{"version":3,"file":"vercel-catalog.d.ts","sourceRoot":"","sources":["../../../src/skills/catalog/vercel-catalog.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,OAAO,KAAK,EAAmB,aAAa,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE7F;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,mDAAmD;IACnD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,oDAAoD;IACpD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,2CAA2C;IAC3C,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAiBD;;;;;;;;GAQG;AACH,wBAAsB,kBAAkB,CAAC,MAAM,GAAE,aAAkB,GAAG,OAAO,CAAC,aAAa,CAAC,CAgC3F;AAkHD;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CACrC,KAAK,SAAK,EACV,MAAM,GAAE,aAAkB,GACzB,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAO/B;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAKzD"}
|
|
@@ -64,15 +64,18 @@ export async function fetchVercelCatalog(config = {}) {
|
|
|
64
64
|
* Load catalog from cache if valid.
|
|
65
65
|
*/
|
|
66
66
|
function loadFromCache(cachePath, ttl) {
|
|
67
|
-
|
|
67
|
+
// Read first to avoid TOCTOU between stat and read (file could disappear between calls)
|
|
68
|
+
let content;
|
|
69
|
+
try {
|
|
70
|
+
content = fs.readFileSync(cachePath, 'utf-8');
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
68
73
|
return null;
|
|
69
74
|
}
|
|
70
|
-
const
|
|
71
|
-
const age = Date.now() - stats.mtimeMs;
|
|
75
|
+
const age = Date.now() - fs.statSync(cachePath).mtimeMs;
|
|
72
76
|
if (age > ttl) {
|
|
73
77
|
return null;
|
|
74
78
|
}
|
|
75
|
-
const content = fs.readFileSync(cachePath, 'utf-8');
|
|
76
79
|
return JSON.parse(content);
|
|
77
80
|
}
|
|
78
81
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"github-loader.d.ts","sourceRoot":"","sources":["../../../src/skills/loader/github-loader.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAOH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAezC;;;;;;GAMG;AACH,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,CA+B9D;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,wCAAwC;IACxC,SAAS,EAAE,MAAM,CAAC;IAElB,uCAAuC;IACvC,KAAK,EAAE,OAAO,GAAG,QAAQ,CAAC;IAE1B,sCAAsC;IACtC,QAAQ,EAAE,aAAa,CAAC;IAExB,6CAA6C;IAC7C,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAE5B,wCAAwC;IACxC,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;;GAIG;AACH,wBAAsB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"github-loader.d.ts","sourceRoot":"","sources":["../../../src/skills/loader/github-loader.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAOH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAezC;;;;;;GAMG;AACH,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,CA+B9D;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,wCAAwC;IACxC,SAAS,EAAE,MAAM,CAAC;IAElB,uCAAuC;IACvC,KAAK,EAAE,OAAO,GAAG,QAAQ,CAAC;IAE1B,sCAAsC;IACtC,QAAQ,EAAE,aAAa,CAAC;IAExB,6CAA6C;IAC7C,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAE5B,wCAAwC;IACxC,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;;GAIG;AACH,wBAAsB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,KAAK,CAAC,CAkE/F;AAmED;;GAEG;AACH,wBAAsB,gBAAgB,CACpC,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,aAAa,GACtB,OAAO,CAAC,KAAK,GAAG,SAAS,CAAC,CAS5B;AAED;;GAEG;AACH,wBAAsB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAY3E"}
|
|
@@ -59,6 +59,8 @@ export function parseGitHubSource(source) {
|
|
|
59
59
|
*/
|
|
60
60
|
export async function loadFromGitHub(source, options) {
|
|
61
61
|
const parsed = parseGitHubSource(source);
|
|
62
|
+
validateGitArg(parsed.owner, 'owner');
|
|
63
|
+
validateGitArg(parsed.repo, 'repo');
|
|
62
64
|
const repoUrl = `https://github.com/${parsed.owner}/${parsed.repo}.git`;
|
|
63
65
|
// Determine skill name from path or repo name
|
|
64
66
|
const skillName = parsed.path ? path.basename(parsed.path) : parsed.repo;
|
|
@@ -94,7 +94,7 @@ export async function loadAllFromDirectory(dir, options) {
|
|
|
94
94
|
skills.push(skill);
|
|
95
95
|
}
|
|
96
96
|
catch {
|
|
97
|
-
// Skip malformed or unreadable skill files
|
|
97
|
+
// Skip malformed or unreadable skill files - partial load is better than a hard crash
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
return skills;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vercel-loader.d.ts","sourceRoot":"","sources":["../../../src/skills/loader/vercel-loader.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,EACV,UAAU,EAIX,MAAM,mBAAmB,CAAC;AAgB3B;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,wCAAwC;IACxC,SAAS,EAAE,MAAM,CAAC;IAElB,uCAAuC;IACvC,KAAK,EAAE,OAAO,GAAG,QAAQ,CAAC;IAE1B,sCAAsC;IACtC,QAAQ,EAAE,aAAa,CAAC;IAExB,6CAA6C;IAC7C,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAE5B,wCAAwC;IACxC,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB,sCAAsC;IACtC,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,KAAK,CAAC,CAgFhB;
|
|
1
|
+
{"version":3,"file":"vercel-loader.d.ts","sourceRoot":"","sources":["../../../src/skills/loader/vercel-loader.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,EACV,UAAU,EAIX,MAAM,mBAAmB,CAAC;AAgB3B;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,wCAAwC;IACxC,SAAS,EAAE,MAAM,CAAC;IAElB,uCAAuC;IACvC,KAAK,EAAE,OAAO,GAAG,QAAQ,CAAC;IAE1B,sCAAsC;IACtC,QAAQ,EAAE,aAAa,CAAC;IAExB,6CAA6C;IAC7C,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAE5B,wCAAwC;IACxC,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB,sCAAsC;IACtC,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,KAAK,CAAC,CAgFhB;AAkLD;;;;;;GAMG;AACH,wBAAsB,uBAAuB,CAC3C,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,aAAa,GACtB,OAAO,CAAC,UAAU,CAAC,CAyCrB;AAED;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CACrC,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,aAAa,GACtB,OAAO,CAAC,KAAK,CAAC,CAwBhB;AAED;;;;GAIG;AACH,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,OAAO,CAAC,CAO7D"}
|
|
@@ -182,6 +182,8 @@ function extractInstallPath(output, baseDir, source) {
|
|
|
182
182
|
* @returns Installation path
|
|
183
183
|
*/
|
|
184
184
|
async function fallbackGitClone(source, targetPath) {
|
|
185
|
+
validateGitArg(source.owner, 'owner');
|
|
186
|
+
validateGitArg(source.repo, 'repo');
|
|
185
187
|
const repoUrl = `https://github.com/${source.owner}/${source.repo}.git`;
|
|
186
188
|
if (source.path) {
|
|
187
189
|
// Use sparse checkout for subdirectory
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { SkillMetadataSchema } from '../types.js';
|
|
7
7
|
// ---------------------------------------------------------------------------
|
|
8
|
-
// Minimal YAML parser/stringifier
|
|
8
|
+
// Minimal YAML parser/stringifier - replaces the `yaml` package.
|
|
9
9
|
// Handles the flat key-value + block-sequence subset used in SKILL.md files.
|
|
10
10
|
// ---------------------------------------------------------------------------
|
|
11
11
|
function yamlParseScalar(s) {
|
|
@@ -48,7 +48,7 @@ function yamlParse(input) {
|
|
|
48
48
|
// Inline array: key: [a, b] OR block sequence (items follow indented with `- `)
|
|
49
49
|
const peek = lines[i]?.trim() ?? '';
|
|
50
50
|
if (peek.startsWith('[')) {
|
|
51
|
-
// inline
|
|
51
|
+
// inline - handled below on next iteration; should not happen in this branch
|
|
52
52
|
}
|
|
53
53
|
const items = [];
|
|
54
54
|
while (i < lines.length) {
|
|
@@ -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"}
|