@revealui/ai 0.2.8 → 0.3.0
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} +10 -10
- 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/pipeline.d.ts +1 -1
- package/dist/ingestion/pipeline.d.ts.map +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 -16
- package/dist/llm/client.d.ts.map +1 -1
- package/dist/llm/client.js +10 -70
- 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/lww-register.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 +12 -2
- 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 +32 -18
- 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/index.d.ts +1 -2
- package/dist/memory/utils/index.d.ts.map +1 -1
- package/dist/memory/utils/index.js +1 -2
- package/dist/memory/utils/sql-helpers.d.ts +0 -39
- package/dist/memory/utils/sql-helpers.d.ts.map +1 -1
- package/dist/memory/utils/sql-helpers.js +0 -88
- 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 +16 -7
- 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 +44 -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
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @revealui/ai
|
|
2
2
|
|
|
3
|
-
> **Commercial package**
|
|
3
|
+
> **Commercial package** - requires a [RevealUI Pro license](https://revealui.com/pro). Free to install and evaluate; a license key is required for production use.
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
AI system for RevealUI - memory, LLM, orchestration, and tools.
|
|
@@ -309,7 +309,7 @@ Potential optimizations (not yet implemented):
|
|
|
309
309
|
|
|
310
310
|
## License
|
|
311
311
|
|
|
312
|
-
Commercial
|
|
312
|
+
Commercial - see [LICENSE.commercial](../../LICENSE.commercial)
|
|
313
313
|
|
|
314
314
|
---
|
|
315
315
|
|
package/dist/a2a/card.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ declare class AgentCardRegistry {
|
|
|
20
20
|
listDefs(): AgentDefinition[];
|
|
21
21
|
has(agentId: string): boolean;
|
|
22
22
|
}
|
|
23
|
-
/** Singleton registry
|
|
23
|
+
/** Singleton registry - import and use directly */
|
|
24
24
|
export declare const agentCardRegistry: AgentCardRegistry;
|
|
25
25
|
export type { AgentDefinition };
|
|
26
26
|
//# sourceMappingURL=card.d.ts.map
|
package/dist/a2a/card.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"card.d.ts","sourceRoot":"","sources":["../../src/a2a/card.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,KAAK,YAAY,EAAyB,MAAM,qBAAqB,CAAC;AAwI/E,cAAM,iBAAiB;IACrB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAsC;;IAO3D,QAAQ,CAAC,GAAG,EAAE,eAAe,GAAG,IAAI;IAIpC,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO;IAIpC,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,eAAe,EAAE,IAAI,GAAG,SAAS,CAAC,CAAC,GAAG,OAAO;IAOzF,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS;IAIpD,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI;IAM9D,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,EAAE;IAI1C,QAAQ,IAAI,eAAe,EAAE;IAI7B,GAAG,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO;CAG9B;AAED,
|
|
1
|
+
{"version":3,"file":"card.d.ts","sourceRoot":"","sources":["../../src/a2a/card.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,KAAK,YAAY,EAAyB,MAAM,qBAAqB,CAAC;AAwI/E,cAAM,iBAAiB;IACrB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAsC;;IAO3D,QAAQ,CAAC,GAAG,EAAE,eAAe,GAAG,IAAI;IAIpC,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO;IAIpC,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,eAAe,EAAE,IAAI,GAAG,SAAS,CAAC,CAAC,GAAG,OAAO;IAOzF,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS;IAIpD,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI;IAM9D,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,EAAE;IAI1C,QAAQ,IAAI,eAAe,EAAE;IAI7B,GAAG,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO;CAG9B;AAED,qDAAqD;AACrD,eAAO,MAAM,iBAAiB,mBAA0B,CAAC;AAEzD,YAAY,EAAE,eAAe,EAAE,CAAC"}
|
package/dist/a2a/card.js
CHANGED
|
@@ -10,7 +10,7 @@ import { agentDefinitionToCard } from '@revealui/contracts';
|
|
|
10
10
|
// =============================================================================
|
|
11
11
|
// Built-in agent definitions
|
|
12
12
|
// =============================================================================
|
|
13
|
-
/** RevealUI platform meta-agent
|
|
13
|
+
/** RevealUI platform meta-agent - "The Creator" */
|
|
14
14
|
const THE_CREATOR_DEF = {
|
|
15
15
|
id: 'revealui-creator',
|
|
16
16
|
version: 1,
|
|
@@ -21,7 +21,7 @@ const THE_CREATOR_DEF = {
|
|
|
21
21
|
model: 'claude-opus-4-6',
|
|
22
22
|
systemPrompt: 'You are The Creator, the meta-agent for RevealUI. You design, configure, and deploy ' +
|
|
23
23
|
'purpose-built AI agents for RevealUI users. You have access to agent scaffolding tools, ' +
|
|
24
|
-
'the RevealUI
|
|
24
|
+
'the RevealUI admin, and the billing system.',
|
|
25
25
|
tools: [
|
|
26
26
|
{
|
|
27
27
|
name: 'scaffoldAgent',
|
|
@@ -73,7 +73,7 @@ const TICKET_AGENT_DEF = {
|
|
|
73
73
|
version: 1,
|
|
74
74
|
name: 'Ticket Agent',
|
|
75
75
|
description: 'Handles support tickets, resolves user issues, and escalates when needed. ' +
|
|
76
|
-
'Uses the RevealUI
|
|
76
|
+
'Uses the RevealUI admin to create and update tickets.',
|
|
77
77
|
model: 'claude-sonnet-4-6',
|
|
78
78
|
systemPrompt: 'You are the RevealUI Ticket Agent. You help users resolve issues by creating tickets, ' +
|
|
79
79
|
'searching for solutions, and escalating complex problems to the support team.',
|
|
@@ -169,5 +169,5 @@ class AgentCardRegistry {
|
|
|
169
169
|
return this.defs.has(agentId);
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
|
-
/** Singleton registry
|
|
172
|
+
/** Singleton registry - import and use directly */
|
|
173
173
|
export const agentCardRegistry = new AgentCardRegistry();
|
package/dist/a2a/handler.d.ts
CHANGED
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
* Integrates with AgentRuntime and AgentOrchestrator from @revealui/ai/orchestration.
|
|
6
6
|
*
|
|
7
7
|
* Supported methods:
|
|
8
|
-
* tasks/send
|
|
9
|
-
* tasks/get
|
|
10
|
-
* tasks/cancel
|
|
11
|
-
* tasks/sendSubscribe
|
|
8
|
+
* tasks/send - synchronous task execution
|
|
9
|
+
* tasks/get - retrieve task by ID
|
|
10
|
+
* tasks/cancel - cancel a running task
|
|
11
|
+
* tasks/sendSubscribe - (handled at route level via SSE; returns taskId here)
|
|
12
12
|
*/
|
|
13
13
|
import type { A2AJsonRpcRequest, A2AJsonRpcResponse } from '@revealui/contracts';
|
|
14
14
|
import type { LLMClient } from '../llm/client.js';
|
package/dist/a2a/handler.js
CHANGED
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
* Integrates with AgentRuntime and AgentOrchestrator from @revealui/ai/orchestration.
|
|
6
6
|
*
|
|
7
7
|
* Supported methods:
|
|
8
|
-
* tasks/send
|
|
9
|
-
* tasks/get
|
|
10
|
-
* tasks/cancel
|
|
11
|
-
* tasks/sendSubscribe
|
|
8
|
+
* tasks/send - synchronous task execution
|
|
9
|
+
* tasks/get - retrieve task by ID
|
|
10
|
+
* tasks/cancel - cancel a running task
|
|
11
|
+
* tasks/sendSubscribe - (handled at route level via SSE; returns taskId here)
|
|
12
12
|
*/
|
|
13
13
|
import { A2ASendTaskParamsSchema } from '@revealui/contracts';
|
|
14
14
|
import { logger } from '@revealui/core/observability/logger';
|
|
@@ -57,7 +57,7 @@ async function handleTasksSend(id, params, agentId, llmClient) {
|
|
|
57
57
|
try {
|
|
58
58
|
// Transition to working
|
|
59
59
|
updateTaskState(task.id, 'working');
|
|
60
|
-
// Execute via orchestration
|
|
60
|
+
// Execute via orchestration - for now, produce a direct text response.
|
|
61
61
|
// Full AgentRuntime integration wires in when an LLM provider is configured.
|
|
62
62
|
const agentDef = agentId
|
|
63
63
|
? agentCardRegistry.getDef(agentId)
|
package/dist/a2a/index.d.ts
CHANGED
package/dist/a2a/index.js
CHANGED
package/dist/audit/emitter.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ import type { AuditEventType, AuditSeverity } from './types.js';
|
|
|
15
15
|
*/
|
|
16
16
|
export interface AuditEmitter {
|
|
17
17
|
/**
|
|
18
|
-
* Emit an audit event. This is a fire-and-forget operation
|
|
18
|
+
* Emit an audit event. This is a fire-and-forget operation -
|
|
19
19
|
* the agent does not receive confirmation or any data back.
|
|
20
20
|
*/
|
|
21
21
|
emit(eventType: AuditEventType, payload: Record<string, unknown>, severity?: AuditSeverity): void;
|
package/dist/audit/emitter.js
CHANGED
|
@@ -20,12 +20,12 @@
|
|
|
20
20
|
export function createAuditEmitter(agentId, handler) {
|
|
21
21
|
const emitter = {
|
|
22
22
|
emit(eventType, payload, severity = 'info') {
|
|
23
|
-
// Fire-and-forget
|
|
23
|
+
// Fire-and-forget - agents don't get feedback from the audit system
|
|
24
24
|
try {
|
|
25
25
|
handler(agentId, eventType, payload, severity);
|
|
26
26
|
}
|
|
27
27
|
catch {
|
|
28
|
-
// Silently swallow errors
|
|
28
|
+
// Silently swallow errors - audit failures must never affect agent execution
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
};
|
package/dist/audit/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* - **Store** is append-only (no updates, no deletes)
|
|
10
10
|
*
|
|
11
11
|
* This architecture ensures that AI agents cannot tamper with, disable,
|
|
12
|
-
* or circumvent the audit trail
|
|
12
|
+
* or circumvent the audit trail - it lives entirely outside their scope.
|
|
13
13
|
*
|
|
14
14
|
* ## Quick Start
|
|
15
15
|
*
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
*
|
|
30
30
|
* // Create write-only emitter for an agent
|
|
31
31
|
* const emitter = observer.createEmitterForAgent('agent-1')
|
|
32
|
-
* // Pass `emitter` to the agent
|
|
32
|
+
* // Pass `emitter` to the agent - it can only call emitter.emit()
|
|
33
33
|
*
|
|
34
34
|
* // Human can halt agents at any time
|
|
35
35
|
* observer.haltAgent('agent-1', 'admin', 'Suspicious behavior')
|
package/dist/audit/index.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* - **Store** is append-only (no updates, no deletes)
|
|
10
10
|
*
|
|
11
11
|
* This architecture ensures that AI agents cannot tamper with, disable,
|
|
12
|
-
* or circumvent the audit trail
|
|
12
|
+
* or circumvent the audit trail - it lives entirely outside their scope.
|
|
13
13
|
*
|
|
14
14
|
* ## Quick Start
|
|
15
15
|
*
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
*
|
|
30
30
|
* // Create write-only emitter for an agent
|
|
31
31
|
* const emitter = observer.createEmitterForAgent('agent-1')
|
|
32
|
-
* // Pass `emitter` to the agent
|
|
32
|
+
* // Pass `emitter` to the agent - it can only call emitter.emit()
|
|
33
33
|
*
|
|
34
34
|
* // Human can halt agents at any time
|
|
35
35
|
* observer.haltAgent('agent-1', 'admin', 'Suspicious behavior')
|
package/dist/audit/store.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Audit Store
|
|
3
3
|
*
|
|
4
4
|
* Append-only storage interface for audit entries.
|
|
5
|
-
* No update or delete operations
|
|
5
|
+
* No update or delete operations - the log is immutable.
|
|
6
6
|
* Includes an in-memory implementation and a pluggable interface
|
|
7
7
|
* for persistent backends (PostgreSQL, etc.).
|
|
8
8
|
*/
|
|
@@ -25,7 +25,7 @@ export interface AuditStore {
|
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
27
|
* In-memory audit store for development and testing.
|
|
28
|
-
* Entries are stored in a simple array
|
|
28
|
+
* Entries are stored in a simple array - not suitable for production.
|
|
29
29
|
*/
|
|
30
30
|
export declare class InMemoryAuditStore implements AuditStore {
|
|
31
31
|
private entries;
|
package/dist/audit/store.js
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
* Audit Store
|
|
3
3
|
*
|
|
4
4
|
* Append-only storage interface for audit entries.
|
|
5
|
-
* No update or delete operations
|
|
5
|
+
* No update or delete operations - the log is immutable.
|
|
6
6
|
* Includes an in-memory implementation and a pluggable interface
|
|
7
7
|
* for persistent backends (PostgreSQL, etc.).
|
|
8
8
|
*/
|
|
9
9
|
// ─── In-Memory Implementation ───────────────────────────────────────────────
|
|
10
10
|
/**
|
|
11
11
|
* In-memory audit store for development and testing.
|
|
12
|
-
* Entries are stored in a simple array
|
|
12
|
+
* Entries are stored in a simple array - not suitable for production.
|
|
13
13
|
*/
|
|
14
14
|
export class InMemoryAuditStore {
|
|
15
15
|
entries = [];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client-safe AI error classes.
|
|
3
|
+
*
|
|
4
|
+
* Lightweight errors for React hooks - no server-side dependencies.
|
|
5
|
+
* Consumers can programmatically handle specific error types (retry on 429, redirect on 401).
|
|
6
|
+
*/
|
|
7
|
+
export declare class AIError extends Error {
|
|
8
|
+
readonly statusCode: number;
|
|
9
|
+
readonly operation: string;
|
|
10
|
+
constructor(message: string, statusCode: number, operation: string);
|
|
11
|
+
}
|
|
12
|
+
export declare function createAIError(operation: string, statusCode: number, statusText: string): AIError;
|
|
13
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/client/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,qBAAa,OAAQ,SAAQ,KAAK;aAGd,UAAU,EAAE,MAAM;aAClB,SAAS,EAAE,MAAM;gBAFjC,OAAO,EAAE,MAAM,EACC,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM;CAKpC;AAED,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAahG"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client-safe AI error classes.
|
|
3
|
+
*
|
|
4
|
+
* Lightweight errors for React hooks - no server-side dependencies.
|
|
5
|
+
* Consumers can programmatically handle specific error types (retry on 429, redirect on 401).
|
|
6
|
+
*/
|
|
7
|
+
export class AIError extends Error {
|
|
8
|
+
statusCode;
|
|
9
|
+
operation;
|
|
10
|
+
constructor(message, statusCode, operation) {
|
|
11
|
+
super(message);
|
|
12
|
+
this.statusCode = statusCode;
|
|
13
|
+
this.operation = operation;
|
|
14
|
+
this.name = 'AIError';
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export function createAIError(operation, statusCode, statusText) {
|
|
18
|
+
const message = statusCode === 401
|
|
19
|
+
? `Authentication required for ${operation}`
|
|
20
|
+
: statusCode === 403
|
|
21
|
+
? `Insufficient permissions for ${operation}`
|
|
22
|
+
: statusCode === 404
|
|
23
|
+
? `Resource not found: ${operation}`
|
|
24
|
+
: statusCode === 429
|
|
25
|
+
? `Too many requests — retry ${operation} shortly`
|
|
26
|
+
: `${operation} failed: ${statusText}`;
|
|
27
|
+
return new AIError(message, statusCode, operation);
|
|
28
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAgentContext.d.ts","sourceRoot":"","sources":["../../../src/client/hooks/useAgentContext.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"useAgentContext.d.ts","sourceRoot":"","sources":["../../../src/client/hooks/useAgentContext.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AASH,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,UAAU,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;IACrC,UAAU,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3D,aAAa,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5E,aAAa,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9C,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3B;AAeD;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,sBAA2B,GACnC,qBAAqB,CAkKvB"}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* Wraps AgentContextManager for client-side usage.
|
|
6
6
|
*/
|
|
7
7
|
import { useCallback, useEffect, useState } from 'react';
|
|
8
|
+
import { createAIError } from '../errors.js';
|
|
8
9
|
const isRecord = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
9
10
|
const parseContextPayload = (payload) => {
|
|
10
11
|
if (!isRecord(payload))
|
|
@@ -37,7 +38,7 @@ export function useAgentContext(sessionId, agentId, options = {}) {
|
|
|
37
38
|
setError(null);
|
|
38
39
|
const response = await fetch(`/api/memory/context/${sessionId}/${agentId}`);
|
|
39
40
|
if (!response.ok) {
|
|
40
|
-
throw
|
|
41
|
+
throw createAIError('load agent context', response.status, response.statusText);
|
|
41
42
|
}
|
|
42
43
|
const payload = (await response.json());
|
|
43
44
|
if (!mounted)
|
|
@@ -65,7 +66,7 @@ export function useAgentContext(sessionId, agentId, options = {}) {
|
|
|
65
66
|
try {
|
|
66
67
|
const response = await fetch(`/api/memory/context/${sessionId}/${agentId}`);
|
|
67
68
|
if (!response.ok) {
|
|
68
|
-
throw
|
|
69
|
+
throw createAIError('sync agent context', response.status, response.statusText);
|
|
69
70
|
}
|
|
70
71
|
const payload = (await response.json());
|
|
71
72
|
setContextState(parseContextPayload(payload));
|
|
@@ -98,7 +99,7 @@ export function useAgentContext(sessionId, agentId, options = {}) {
|
|
|
98
99
|
body: JSON.stringify({ [key]: value }),
|
|
99
100
|
});
|
|
100
101
|
if (!response.ok) {
|
|
101
|
-
throw
|
|
102
|
+
throw createAIError('update context', response.status, response.statusText);
|
|
102
103
|
}
|
|
103
104
|
const payload = (await response.json());
|
|
104
105
|
setContextState(parseContextPayload(payload));
|
|
@@ -118,7 +119,7 @@ export function useAgentContext(sessionId, agentId, options = {}) {
|
|
|
118
119
|
body: JSON.stringify(updates),
|
|
119
120
|
});
|
|
120
121
|
if (!response.ok) {
|
|
121
|
-
throw
|
|
122
|
+
throw createAIError('update context', response.status, response.statusText);
|
|
122
123
|
}
|
|
123
124
|
const payload = (await response.json());
|
|
124
125
|
setContextState(parseContextPayload(payload));
|
|
@@ -138,7 +139,7 @@ export function useAgentContext(sessionId, agentId, options = {}) {
|
|
|
138
139
|
body: JSON.stringify({ key }),
|
|
139
140
|
});
|
|
140
141
|
if (!response.ok) {
|
|
141
|
-
throw
|
|
142
|
+
throw createAIError('remove context key', response.status, response.statusText);
|
|
142
143
|
}
|
|
143
144
|
const payload = (await response.json());
|
|
144
145
|
setContextState(parseContextPayload(payload));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* useAgentStream
|
|
2
|
+
* useAgentStream - React hook for streaming agent responses via SSE
|
|
3
3
|
*
|
|
4
|
-
* Uses fetch + ReadableStream (NOT EventSource
|
|
4
|
+
* Uses fetch + ReadableStream (NOT EventSource - it doesn't support POST).
|
|
5
5
|
* Accumulates AgentStreamChunks into state and exposes:
|
|
6
6
|
* - text: accumulated output text
|
|
7
7
|
* - chunks: all received chunks in order
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* useAgentStream
|
|
2
|
+
* useAgentStream - React hook for streaming agent responses via SSE
|
|
3
3
|
*
|
|
4
|
-
* Uses fetch + ReadableStream (NOT EventSource
|
|
4
|
+
* Uses fetch + ReadableStream (NOT EventSource - it doesn't support POST).
|
|
5
5
|
* Accumulates AgentStreamChunks into state and exposes:
|
|
6
6
|
* - text: accumulated output text
|
|
7
7
|
* - chunks: all received chunks in order
|
|
@@ -80,7 +80,7 @@ export function useAgentStream() {
|
|
|
80
80
|
}));
|
|
81
81
|
}
|
|
82
82
|
catch {
|
|
83
|
-
// Malformed SSE data
|
|
83
|
+
// Malformed SSE data - skip
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useEpisodicMemory.d.ts","sourceRoot":"","sources":["../../../src/client/hooks/useEpisodicMemory.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"useEpisodicMemory.d.ts","sourceRoot":"","sources":["../../../src/client/hooks/useEpisodicMemory.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAQ9D,MAAM,WAAW,uBAAuB;IACtC,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,SAAS,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IACpD,YAAY,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAClD,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,WAAW,GAAG,SAAS,CAAC;IACzD,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;IAClD,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B;AAmCD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,uBAAuB,CA4KzE"}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* React hook for managing episodic memory in client components.
|
|
5
5
|
*/
|
|
6
6
|
import { useCallback, useEffect, useState } from 'react';
|
|
7
|
+
import { createAIError } from '../errors.js';
|
|
7
8
|
const isRecord = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
8
9
|
const isAgentMemory = (value) => {
|
|
9
10
|
if (!isRecord(value))
|
|
@@ -43,7 +44,7 @@ export function useEpisodicMemory(userId) {
|
|
|
43
44
|
setError(null);
|
|
44
45
|
const response = await fetch(`/api/memory/episodic/${userId}`);
|
|
45
46
|
if (!response.ok) {
|
|
46
|
-
throw
|
|
47
|
+
throw createAIError('load episodic memory', response.status, response.statusText);
|
|
47
48
|
}
|
|
48
49
|
const payload = (await response.json());
|
|
49
50
|
if (!mounted)
|
|
@@ -75,7 +76,7 @@ export function useEpisodicMemory(userId) {
|
|
|
75
76
|
setError(null);
|
|
76
77
|
const response = await fetch(`/api/memory/episodic/${userId}`);
|
|
77
78
|
if (!response.ok) {
|
|
78
|
-
throw
|
|
79
|
+
throw createAIError('refresh episodic memory', response.status, response.statusText);
|
|
79
80
|
}
|
|
80
81
|
const payload = (await response.json());
|
|
81
82
|
const parsed = parseEpisodicPayload(payload);
|
|
@@ -100,7 +101,7 @@ export function useEpisodicMemory(userId) {
|
|
|
100
101
|
body: JSON.stringify(memory),
|
|
101
102
|
});
|
|
102
103
|
if (!response.ok) {
|
|
103
|
-
throw
|
|
104
|
+
throw createAIError('add memory', response.status, response.statusText);
|
|
104
105
|
}
|
|
105
106
|
const payload = (await response.json());
|
|
106
107
|
const parsed = parseEpisodicPayload(payload);
|
|
@@ -121,7 +122,7 @@ export function useEpisodicMemory(userId) {
|
|
|
121
122
|
method: 'DELETE',
|
|
122
123
|
});
|
|
123
124
|
if (!response.ok) {
|
|
124
|
-
throw
|
|
125
|
+
throw createAIError('remove memory', response.status, response.statusText);
|
|
125
126
|
}
|
|
126
127
|
// Refresh to get updated list
|
|
127
128
|
await refresh();
|
|
@@ -144,7 +145,7 @@ export function useEpisodicMemory(userId) {
|
|
|
144
145
|
body: JSON.stringify({ query, options: { limit: 20, threshold: 0.5 } }),
|
|
145
146
|
});
|
|
146
147
|
if (!response.ok) {
|
|
147
|
-
throw
|
|
148
|
+
throw createAIError('search memory', response.status, response.statusText);
|
|
148
149
|
}
|
|
149
150
|
const data = (await response.json());
|
|
150
151
|
if (data.results && Array.isArray(data.results)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useWorkingMemory.d.ts","sourceRoot":"","sources":["../../../src/client/hooks/useWorkingMemory.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"useWorkingMemory.d.ts","sourceRoot":"","sources":["../../../src/client/hooks/useWorkingMemory.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AASH,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,UAAU,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAChE,aAAa,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5E,eAAe,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;IAC1C,eAAe,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAChE,YAAY,EAAE;QACZ,MAAM,EAAE,QAAQ,GAAG,QAAQ,GAAG,WAAW,CAAC;QAC1C,KAAK,CAAC,EAAE;YACN,MAAM,CAAC,EAAE,MAAM,CAAC;YAChB,MAAM,CAAC,EAAE,MAAM,CAAC;YAChB,OAAO,CAAC,EAAE,MAAM,CAAC;YACjB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;SACtB,CAAC;QACF,WAAW,CAAC,EAAE;YACZ,EAAE,EAAE,MAAM,CAAC;YACX,WAAW,EAAE,MAAM,CAAC;YACpB,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,CAAC;YACvD,QAAQ,CAAC,EAAE,MAAM,CAAC;SACnB,CAAC;KACH,CAAC;IACF,kBAAkB,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,sBAAsB,CAAC,cAAc,CAAC,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9F,YAAY,EAAE,KAAK,CAAC;QAClB,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;QACpB,KAAK,EAAE,MAAM,CAAC;QACd,YAAY,EAAE,MAAM,CAAC;QACrB,KAAK,EAAE,OAAO,EAAE,CAAC;QACjB,YAAY,EAAE,MAAM,EAAE,CAAC;QACvB,WAAW,EAAE,MAAM,CAAC;QACpB,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC,CAAC;IACH,QAAQ,EAAE,CAAC,KAAK,EAAE,sBAAsB,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9E,WAAW,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAChD,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3B;AAiHD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,uBAA4B,GACpC,sBAAsB,CA6NxB"}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* React hook for managing working memory in client components.
|
|
5
5
|
*/
|
|
6
6
|
import { useCallback, useEffect, useState } from 'react';
|
|
7
|
+
import { createAIError } from '../errors.js';
|
|
7
8
|
const isRecord = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
8
9
|
const isSessionStatus = (value) => value === 'active' || value === 'paused' || value === 'completed';
|
|
9
10
|
const isTaskStatus = (value) => value === 'pending' || value === 'running' || value === 'completed' || value === 'failed';
|
|
@@ -110,7 +111,7 @@ export function useWorkingMemory(sessionId, options = {}) {
|
|
|
110
111
|
setError(null);
|
|
111
112
|
const response = await fetch(`/api/memory/working/${sessionId}`);
|
|
112
113
|
if (!response.ok) {
|
|
113
|
-
throw
|
|
114
|
+
throw createAIError('load working memory', response.status, response.statusText);
|
|
114
115
|
}
|
|
115
116
|
const payload = (await response.json());
|
|
116
117
|
if (!mounted)
|
|
@@ -141,7 +142,7 @@ export function useWorkingMemory(sessionId, options = {}) {
|
|
|
141
142
|
try {
|
|
142
143
|
const response = await fetch(`/api/memory/working/${sessionId}`);
|
|
143
144
|
if (!response.ok) {
|
|
144
|
-
throw
|
|
145
|
+
throw createAIError('sync working memory', response.status, response.statusText);
|
|
145
146
|
}
|
|
146
147
|
const payload = (await response.json());
|
|
147
148
|
const parsed = parseWorkingPayload(payload);
|
|
@@ -173,7 +174,7 @@ export function useWorkingMemory(sessionId, options = {}) {
|
|
|
173
174
|
body: JSON.stringify({ context: newContext }),
|
|
174
175
|
});
|
|
175
176
|
if (!response.ok) {
|
|
176
|
-
throw
|
|
177
|
+
throw createAIError('update context', response.status, response.statusText);
|
|
177
178
|
}
|
|
178
179
|
const payload = (await response.json());
|
|
179
180
|
setContextState(parseContextPayload(payload));
|
|
@@ -206,7 +207,7 @@ export function useWorkingMemory(sessionId, options = {}) {
|
|
|
206
207
|
body: JSON.stringify({ sessionState: state }),
|
|
207
208
|
});
|
|
208
209
|
if (!response.ok) {
|
|
209
|
-
throw
|
|
210
|
+
throw createAIError('update session state', response.status, response.statusText);
|
|
210
211
|
}
|
|
211
212
|
const payload = (await response.json());
|
|
212
213
|
setSessionStateState(parseSessionPayload(payload));
|
|
@@ -227,7 +228,7 @@ export function useWorkingMemory(sessionId, options = {}) {
|
|
|
227
228
|
body: JSON.stringify({ activeAgents: newAgents }),
|
|
228
229
|
});
|
|
229
230
|
if (!response.ok) {
|
|
230
|
-
throw
|
|
231
|
+
throw createAIError('add agent', response.status, response.statusText);
|
|
231
232
|
}
|
|
232
233
|
const payload = (await response.json());
|
|
233
234
|
setActiveAgents(parseActiveAgentsPayload(payload));
|
|
@@ -248,7 +249,7 @@ export function useWorkingMemory(sessionId, options = {}) {
|
|
|
248
249
|
body: JSON.stringify({ activeAgents: newAgents }),
|
|
249
250
|
});
|
|
250
251
|
if (!response.ok) {
|
|
251
|
-
throw
|
|
252
|
+
throw createAIError('remove agent', response.status, response.statusText);
|
|
252
253
|
}
|
|
253
254
|
const payload = (await response.json());
|
|
254
255
|
setActiveAgents(parseActiveAgentsPayload(payload));
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Functions for generating embeddings using the configured LLM provider.
|
|
5
5
|
* Provider is auto-detected from env vars (OLLAMA_BASE_URL → GROQ → ANTHROPIC).
|
|
6
6
|
* For local/free inference use Ollama with `nomic-embed-text`.
|
|
7
|
-
* Note: Groq and Anthropic do not support embeddings
|
|
7
|
+
* Note: Groq and Anthropic do not support embeddings - use Ollama for embedding tasks.
|
|
8
8
|
*/
|
|
9
9
|
import z from 'zod/v4';
|
|
10
10
|
declare const EmbeddingSchema: z.ZodObject<{
|
package/dist/embeddings/index.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Functions for generating embeddings using the configured LLM provider.
|
|
5
5
|
* Provider is auto-detected from env vars (OLLAMA_BASE_URL → GROQ → ANTHROPIC).
|
|
6
6
|
* For local/free inference use Ollama with `nomic-embed-text`.
|
|
7
|
-
* Note: Groq and Anthropic do not support embeddings
|
|
7
|
+
* Note: Groq and Anthropic do not support embeddings - use Ollama for embedding tasks.
|
|
8
8
|
*/
|
|
9
9
|
import z from 'zod/v4';
|
|
10
10
|
import { createLLMClientFromEnv } from '../llm/client.js';
|
|
@@ -41,9 +41,9 @@ export async function generateEmbedding(text, options = {}) {
|
|
|
41
41
|
if (!text || typeof text !== 'string' || text.trim().length === 0) {
|
|
42
42
|
throw new Error('Text must be a non-empty string');
|
|
43
43
|
}
|
|
44
|
-
// Use unified LLM client
|
|
44
|
+
// Use unified LLM client - auto-detects provider from env vars
|
|
45
45
|
const client = createLLMClientFromEnv();
|
|
46
|
-
// Ask client to embed
|
|
46
|
+
// Ask client to embed - each provider uses its own default model when model is undefined
|
|
47
47
|
const result = await client.embed(text, model ? { model } : undefined);
|
|
48
48
|
// If provider returned batch, pick first
|
|
49
49
|
const embeddingResult = Array.isArray(result) ? result[0] : result;
|
|
@@ -66,7 +66,7 @@ export async function generateEmbedding(text, options = {}) {
|
|
|
66
66
|
* @returns Array of embeddings in the same order as input texts
|
|
67
67
|
*/
|
|
68
68
|
export async function generateEmbeddings(texts, options = {}) {
|
|
69
|
-
// Generate in parallel
|
|
69
|
+
// Generate in parallel - providers that support batch (Ollama, OpenAI) can be
|
|
70
70
|
// optimised later by passing the full array directly to client.embed()
|
|
71
71
|
const embeddings = await Promise.all(texts.map((text) => generateEmbedding(text, options)));
|
|
72
72
|
return embeddings;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Context Budget Policy
|
|
3
3
|
* Model-tier-aware context allocation for the coding agent.
|
|
4
|
-
* Ensures small models (
|
|
4
|
+
* Ensures small models (Gemma 4 E2B) get only essential context,
|
|
5
5
|
* while large models (Claude, GPT-4) get full context.
|
|
6
6
|
*/
|
|
7
7
|
export type ModelTier = 'small' | 'medium' | 'large';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Context Budget Policy
|
|
3
3
|
* Model-tier-aware context allocation for the coding agent.
|
|
4
|
-
* Ensures small models (
|
|
4
|
+
* Ensures small models (Gemma 4 E2B) get only essential context,
|
|
5
5
|
* while large models (Claude, GPT-4) get full context.
|
|
6
6
|
*/
|
|
7
7
|
const BUDGETS = {
|
|
@@ -33,7 +33,7 @@ const BUDGETS = {
|
|
|
33
33
|
/** Known model patterns → tier mapping */
|
|
34
34
|
const MODEL_TIER_PATTERNS = [
|
|
35
35
|
// Small: local quantized models
|
|
36
|
-
{ pattern: /
|
|
36
|
+
{ pattern: /gemma4.*e2b/i, tier: 'small' },
|
|
37
37
|
{ pattern: /tinyllama/i, tier: 'small' },
|
|
38
38
|
{ pattern: /phi-[12]/i, tier: 'small' },
|
|
39
39
|
{ pattern: /\b[12]b\b/i, tier: 'small' },
|
|
@@ -44,7 +44,7 @@ const MODEL_TIER_PATTERNS = [
|
|
|
44
44
|
{ pattern: /gemma.*[79]b/i, tier: 'medium' },
|
|
45
45
|
{ pattern: /llama.*70b/i, tier: 'medium' },
|
|
46
46
|
{ pattern: /mixtral/i, tier: 'medium' },
|
|
47
|
-
{ pattern: /qwen
|
|
47
|
+
{ pattern: /qwen.*\d{1,3}b/i, tier: 'medium' },
|
|
48
48
|
{ pattern: /deepseek.*[78]b/i, tier: 'medium' },
|
|
49
49
|
// Large: cloud models with large context
|
|
50
50
|
{ pattern: /claude/i, tier: 'large' },
|
|
@@ -61,7 +61,7 @@ export function classifyModel(modelName) {
|
|
|
61
61
|
if (pattern.test(modelName))
|
|
62
62
|
return tier;
|
|
63
63
|
}
|
|
64
|
-
// Default to medium
|
|
64
|
+
// Default to medium - safe middle ground
|
|
65
65
|
return 'medium';
|
|
66
66
|
}
|
|
67
67
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Inference utilities
|
|
2
|
+
* Inference utilities - context budget, compression, and task decomposition.
|
|
3
3
|
*/
|
|
4
4
|
export { type ContextBudget, classifyModel, getContextBudget, getContextBudgetForModel, type ModelTier, pruneHistory, truncateToolResult, } from './context-budget.js';
|
|
5
5
|
export { compressContext } from './overflow-compressor.js';
|
package/dist/inference/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Inference utilities
|
|
2
|
+
* Inference utilities - context budget, compression, and task decomposition.
|
|
3
3
|
*/
|
|
4
4
|
export { classifyModel, getContextBudget, getContextBudgetForModel, pruneHistory, truncateToolResult, } from './context-budget.js';
|
|
5
5
|
export { compressContext } from './overflow-compressor.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* RAG Query
|
|
2
|
+
* RAG Query - Retrieval-Augmented Generation
|
|
3
3
|
*
|
|
4
4
|
* Generates an embedding for the query, searches the rag_chunks table via
|
|
5
5
|
* pgvector cosine distance, assembles ranked context with recency weighting,
|
|
@@ -14,7 +14,7 @@ export interface RAGOptions {
|
|
|
14
14
|
limit?: number;
|
|
15
15
|
/** Minimum cosine similarity threshold 0–1 (default 0.6) */
|
|
16
16
|
threshold?: number;
|
|
17
|
-
/** Custom embedding function
|
|
17
|
+
/** Custom embedding function - defaults to generateEmbedding() */
|
|
18
18
|
embeddingFn?: (text: string) => Promise<number[]>;
|
|
19
19
|
/** search mode: 'speed' (vector-only) | 'accuracy' (BM25 hybrid + optional rerank) */
|
|
20
20
|
mode?: 'speed' | 'accuracy';
|
|
@@ -22,7 +22,7 @@ export interface RAGOptions {
|
|
|
22
22
|
llmClient?: LLMClient;
|
|
23
23
|
/** Maximum tokens for assembled context (default 2000) */
|
|
24
24
|
maxContextTokens?: number;
|
|
25
|
-
/** Filter to a specific
|
|
25
|
+
/** Filter to a specific admin collection */
|
|
26
26
|
sourceCollection?: string;
|
|
27
27
|
}
|
|
28
28
|
/**
|