elsium-ai 0.10.0 → 0.11.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/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +454 -231
- package/package.json +12 -12
package/dist/index.d.ts
CHANGED
|
@@ -13,16 +13,16 @@ export { ElsiumError, ok, err, isOk, isErr, unwrap, unwrapOr, tryCatch, tryCatch
|
|
|
13
13
|
export type { Role, ContentPart, TextContent, ImageContent, AudioContent, DocumentContent, Message, ToolCall, ToolResult, TokenUsage, CostBreakdown, StopReason, LLMResponse, StreamEvent, XRayData, StreamCheckpoint, ProviderConfig, CompletionRequest, ToolDefinition, TenantContext, Middleware, MiddlewareContext, MiddlewareNext, StreamMiddleware, StreamMiddlewareNext, Result, Ok, Err, ResilientStreamOptions, StreamTransformer, LogLevel, Logger, LogEntry, LoggerOptions, ErrorCode, ErrorDetails, Registry, ContextStrategy, ContextManagerConfig, ContextManager, CircuitBreakerConfig, CircuitBreaker, CircuitState, DedupConfig, Dedup, PolicyDecision, PolicyResult, PolicyContext, PolicyRule, PolicyConfig, PolicySet, ShutdownConfig, ShutdownManager, } from '@elsium-ai/core';
|
|
14
14
|
export { gateway, registerProviderFactory, registerProvider, getProviderFactory, listProviders, registerProviderMetadata, getProviderMetadata, calculateCost, registerPricing, estimateCost, composeMiddleware, composeStreamMiddleware, loggingMiddleware, costTrackingMiddleware, xrayMiddleware, createAnthropicProvider, createOpenAIProvider, createGoogleProvider, createOpenAICompatibleProvider, createProviderMesh, securityMiddleware, detectPromptInjection, detectJailbreak, redactSecrets, checkBlockedPatterns, classifyContent, cacheMiddleware, createInMemoryCache, outputGuardrailMiddleware, createBatch, createBulkhead, bulkheadMiddleware, } from '@elsium-ai/gateway';
|
|
15
15
|
export type { LLMProvider, ProviderFactory, ProviderMetadata, ModelPricing, ModelTier, Gateway, GatewayConfig, ExtractOptions, XRayStore, ProviderMeshConfig, ProviderEntry, RoutingStrategy, ProviderMesh, MeshAuditLogger, SecurityMiddlewareConfig, SecurityViolation, SecurityResult, DataClassification, ClassificationResult, OpenAICompatibleConfig, CacheAdapter, CacheStats, CacheMiddlewareConfig, OutputGuardrailConfig, OutputGuardrailRule, OutputViolation, BatchConfig, BatchResult, BatchResultItem, BulkheadConfig, Bulkhead, } from '@elsium-ai/gateway';
|
|
16
|
-
export { defineAgent, runSequential, runParallel, runSupervisor, createMemory, createSummarizeFn, createSemanticValidator, createAgentSecurity, createConfidenceScorer, executeStateMachine, defineReActAgent, createInMemoryMemoryStore, createSqliteMemoryStore, createSharedMemory, createAgentStream, createThread, loadThread, createInMemoryThreadStore, createAsyncAgent, createApprovalGate, shouldRequireApproval, createChannelGateway, createWebhookChannel, createSessionRouter, createScheduler, parseCronExpression, cronMatchesDate, getNextCronDate, createAgentIdentity, createIdentityRegistry, createRuntimePolicyEnforcer, toolAccessPolicy, iterationLimitPolicy, createSecureMemoryStore, computeMessageHash, verifyMessageChain, } from '@elsium-ai/agents';
|
|
17
|
-
export type { Agent, AgentDependencies, AgentGenerateResult, AgentConfig, AgentResult, AgentRunOptions, GuardrailConfig, AgentHooks, Memory, MemoryConfig, SummarizeFn, SemanticGuardrailConfig, SemanticCheck, SemanticCheckResult, SemanticValidationResult, SemanticValidator, AgentSecurityConfig, AgentSecurityResult, ConfidenceConfig, ConfidenceResult, StateDefinition, StateHistoryEntry, StateMachineResult, ReActConfig, ReActResult, ReActStep, ReActAgent, MultiAgentConfig, MultiAgentOptions, MemoryStore, SqliteMemoryStoreConfig, SharedMemory, AgentStreamEvent, AgentStream, StreamingAgentDependencies, Thread, ThreadConfig, ThreadStore, ThreadSnapshot, ThreadSummary, AsyncAgent, AsyncAgentConfig, AsyncAgentRunOptions, AgentTask, TaskStatus, TaskProgressEvent, ApprovalRequest, ApprovalDecision, ApprovalCallback, ApprovalGateConfig, ApprovalGate, ChannelAdapter, ChannelGateway, ChannelGatewayConfig, IncomingMessage, OutgoingMessage, ChannelAttachment, WebhookChannelConfig, SessionRouter, SessionRouterConfig, SessionInfo, SessionResolveOptions, Scheduler, SchedulerConfig, ScheduleOptions, ScheduledTask, CronFields, AgentIdentity, AgentIdentityConfig, SignedPayload, VerificationResult, IdentityRegistry, RuntimePolicyConfig, RuntimePolicyEnforcer, ToolPolicyContext, SecureMemoryStore, IntegrityMetadata, VerifiedMessage, MemoryIntegrityResult, } from '@elsium-ai/agents';
|
|
16
|
+
export { defineAgent, runSequential, runParallel, runSupervisor, createMemory, createSummarizeFn, createSemanticValidator, createAgentSecurity, createConfidenceScorer, executeStateMachine, defineReActAgent, createInMemoryMemoryStore, createSqliteMemoryStore, createSharedMemory, createAgentStream, createThread, loadThread, createInMemoryThreadStore, createAsyncAgent, createInMemoryTaskStore, createJsonFileTaskStore, createApprovalGate, shouldRequireApproval, createChannelGateway, createWebhookChannel, createSessionRouter, createScheduler, parseCronExpression, cronMatchesDate, getNextCronDate, createAgentIdentity, createIdentityRegistry, createRuntimePolicyEnforcer, toolAccessPolicy, iterationLimitPolicy, createSecureMemoryStore, computeMessageHash, verifyMessageChain, } from '@elsium-ai/agents';
|
|
17
|
+
export type { Agent, AgentDependencies, AgentGenerateResult, AgentConfig, AgentResult, AgentRunOptions, GuardrailConfig, AgentHooks, Memory, MemoryConfig, SummarizeFn, SemanticGuardrailConfig, SemanticCheck, SemanticCheckResult, SemanticValidationResult, SemanticValidator, AgentSecurityConfig, AgentSecurityResult, ConfidenceConfig, ConfidenceResult, StateDefinition, StateHistoryEntry, StateMachineResult, ReActConfig, ReActResult, ReActStep, ReActAgent, MultiAgentConfig, MultiAgentOptions, MemoryStore, SqliteMemoryStoreConfig, SharedMemory, AgentStreamEvent, AgentStream, StreamingAgentDependencies, Thread, ThreadConfig, ThreadStore, ThreadSnapshot, ThreadSummary, AsyncAgent, AsyncAgentConfig, AsyncAgentRunOptions, AgentTask, TaskStatus, TaskProgressEvent, TaskStore, TaskStoreFilter, PersistedTask, PersistedTaskError, JsonFileTaskStoreConfig, ApprovalRequest, ApprovalDecision, ApprovalCallback, ApprovalGateConfig, ApprovalGate, ChannelAdapter, ChannelGateway, ChannelGatewayConfig, IncomingMessage, OutgoingMessage, ChannelAttachment, WebhookChannelConfig, SessionRouter, SessionRouterConfig, SessionInfo, SessionResolveOptions, Scheduler, SchedulerConfig, ScheduleOptions, ScheduledTask, CronFields, AgentIdentity, AgentIdentityConfig, SignedPayload, VerificationResult, IdentityRegistry, RuntimePolicyConfig, RuntimePolicyEnforcer, ToolPolicyContext, SecureMemoryStore, IntegrityMetadata, VerifiedMessage, MemoryIntegrityResult, } from '@elsium-ai/agents';
|
|
18
18
|
export { defineTool, createToolkit, httpFetchTool, calculatorTool, jsonParseTool, currentTimeTool, formatToolResult, formatToolResultAsText, createRetrievalTool, } from '@elsium-ai/tools';
|
|
19
19
|
export type { Tool, ToolConfig, ToolContext, ToolExecutionResult, Toolkit, RetrievalToolConfig, RetrievalResult as ToolRetrievalResult, RetrieveFn, } from '@elsium-ai/tools';
|
|
20
20
|
export { rag, createInMemoryStore, createOpenAIEmbeddings, createMockEmbeddings, textLoader, markdownLoader, htmlLoader, jsonLoader, csvLoader, getLoader, pdfLoader, fixedSizeChunker, recursiveChunker, sentenceChunker, getChunker, cosineSimilarity, mmrRerank, vectorStoreRegistry, embeddingProviderRegistry, createPgVectorStore, createQdrantStore, createGoogleEmbeddings, createCohereEmbeddings, createBM25Index, createHybridSearch, } from '@elsium-ai/rag';
|
|
21
21
|
export type { RAGPipeline, RAGPipelineConfig, IngestResult, Document, DocumentMetadata, Chunk, ChunkMetadata, EmbeddedChunk, EmbeddingVector, RetrievalResult, QueryOptions, LoaderType, ChunkingStrategy, ChunkingConfig, EmbeddingConfig, VectorStoreConfig, RetrievalConfig, EmbeddingProvider, VectorStore, VectorStoreFactory, EmbeddingProviderFactory, DocumentLoader, Chunker, PgVectorStoreConfig, QdrantStoreConfig, GoogleEmbeddingsConfig, CohereEmbeddingsConfig, BinaryDocumentLoader, PdfLoaderOptions, BM25Index, HybridSearch, HybridSearchConfig, } from '@elsium-ai/rag';
|
|
22
22
|
export { defineWorkflow, defineParallelWorkflow, defineBranchWorkflow, defineDagWorkflow, defineResumableWorkflow, createInMemoryCheckpointStore, step, } from '@elsium-ai/workflows';
|
|
23
23
|
export type { Workflow, WorkflowConfig, WorkflowResult, WorkflowRunOptions, WorkflowStatus, StepConfig, StepContext, StepResult, StepStatus, RetryConfig, ParallelWorkflowConfig, BranchConfig, DagStepConfig, DagWorkflowConfig, ResumableWorkflow, ResumableWorkflowConfig, ResumableWorkflowRunOptions, WorkflowCheckpoint, CheckpointStore, } from '@elsium-ai/workflows';
|
|
24
|
-
export { observe, createSpan, createMetrics, createCostEngine, registerModelTier, createAuditTrail, auditMiddleware, auditStreamMiddleware, createSinkManager, createWebhookSink, createSplunkSink, createDatadogSink, createProvenanceTracker, createExperiment, createFileExperimentStore, instrumentComplete, instrumentAgent, createStudioExporter, generateComplianceReport, formatComplianceReport, toOTelSpan, toOTelExportRequest, toTraceparent, parseTraceparent, injectTraceContext, extractTraceContext, createOTLPExporter, } from '@elsium-ai/observe';
|
|
25
|
-
export type { Tracer, TracerConfig, TracerExporter, TracerOutput, CostReport, Span, SpanData, SpanEvent, SpanKind, SpanStatus, SpanHandler, MetricsCollector, MetricEntry, CostEngine, CostEngineConfig, BudgetConfig, LoopDetectionConfig, CostAlert, CostDimension, CostIntelligenceReport, ModelSuggestion, ModelTierEntry, AuditEventType, AuditEvent, AuditStorageAdapter, AuditQueryFilter, AuditIntegrityResult, AuditTrailConfig, AuditBatchConfig, AuditTrail, AuditSink, AuditSinkRetryConfig, SinkManagerConfig, SinkManager, WebhookSinkConfig, SplunkSinkConfig, DatadogSinkConfig, ProvenanceRecord, ProvenanceTracker, Experiment, ExperimentConfig, ExperimentVariant, ExperimentResults, ExperimentStore, InstrumentableAgent, StudioExporter, StudioExporterConfig, ComplianceFramework, ComplianceReportConfig, ComplianceCheck, ComplianceCheckResult, ComplianceReport, ComplianceSummary, ComplianceReportEntry, OTelSpan, OTelSpanKind, OTelStatusCode, OTelAttribute, OTelAttributeValue, OTelEvent, OTelResource, OTelExportRequest, TraceContext, OTLPExporterConfig, } from '@elsium-ai/observe';
|
|
24
|
+
export { observe, createSpan, createMetrics, createCostEngine, registerModelTier, createAuditTrail, auditMiddleware, auditStreamMiddleware, createSinkManager, createWebhookSink, createSplunkSink, createDatadogSink, createJsonlSink, createProvenanceTracker, createExperiment, createFileExperimentStore, instrumentComplete, instrumentAgent, createStudioExporter, generateComplianceReport, formatComplianceReport, toOTelSpan, toOTelExportRequest, toTraceparent, parseTraceparent, injectTraceContext, extractTraceContext, createOTLPExporter, } from '@elsium-ai/observe';
|
|
25
|
+
export type { Tracer, TracerConfig, TracerExporter, TracerOutput, CostReport, Span, SpanData, SpanEvent, SpanKind, SpanStatus, SpanHandler, MetricsCollector, MetricEntry, CostEngine, CostEngineConfig, BudgetConfig, LoopDetectionConfig, CostAlert, CostDimension, CostIntelligenceReport, ModelSuggestion, ModelTierEntry, AuditEventType, AuditEvent, AuditStorageAdapter, AuditQueryFilter, AuditIntegrityResult, AuditTrailConfig, AuditBatchConfig, AuditTrail, AuditSink, AuditSinkRetryConfig, SinkManagerConfig, SinkManager, WebhookSinkConfig, SplunkSinkConfig, DatadogSinkConfig, JsonlSinkConfig, ProvenanceRecord, ProvenanceTracker, Experiment, ExperimentConfig, ExperimentVariant, ExperimentResults, ExperimentStore, InstrumentableAgent, StudioExporter, StudioExporterConfig, ComplianceFramework, ComplianceReportConfig, ComplianceCheck, ComplianceCheckResult, ComplianceReport, ComplianceSummary, ComplianceReportEntry, OTelSpan, OTelSpanKind, OTelStatusCode, OTelAttribute, OTelAttributeValue, OTelEvent, OTelResource, OTelExportRequest, TraceContext, OTLPExporterConfig, } from '@elsium-ai/observe';
|
|
26
26
|
export { createApp, sseHeaders, formatSSE, streamResponse, tenantMiddleware, tenantRateLimitMiddleware, } from '@elsium-ai/app';
|
|
27
27
|
export type { AppConfig, ServerConfig, CorsConfig, AuthConfig, RateLimitConfig, StreamChatEvent, StreamCompleteEvent, TenantMiddlewareConfig, } from '@elsium-ai/app';
|
|
28
28
|
export { createMCPClient, createMCPServer, createMCPHttpHandler, createTrustedMCPClient, } from '@elsium-ai/mcp';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAEN,WAAW,EAEX,EAAE,EACF,GAAG,EACH,IAAI,EACJ,KAAK,EACL,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,YAAY,EAEZ,YAAY,EACZ,YAAY,EAEZ,YAAY,EAEZ,GAAG,EACH,SAAS,EACT,OAAO,EAEP,UAAU,EACV,eAAe,EACf,WAAW,EACX,KAAK,EACL,KAAK,EAEL,eAAe,EAEf,cAAc,EAEd,WAAW,EACX,oBAAoB,EAEpB,oBAAoB,EAEpB,WAAW,EACX,eAAe,EAEf,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,aAAa,EAEb,qBAAqB,GACrB,MAAM,iBAAiB,CAAA;AAExB,YAAY,EAEX,IAAI,EACJ,WAAW,EACX,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,OAAO,EACP,QAAQ,EACR,UAAU,EACV,UAAU,EACV,aAAa,EACb,UAAU,EACV,WAAW,EACX,WAAW,EACX,QAAQ,EACR,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EACjB,cAAc,EACd,aAAa,EACb,UAAU,EACV,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,oBAAoB,EAEpB,MAAM,EACN,EAAE,EACF,GAAG,EAEH,sBAAsB,EACtB,iBAAiB,EAEjB,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,aAAa,EAEb,SAAS,EACT,YAAY,EAEZ,QAAQ,EAER,eAAe,EACf,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AAgB,EAChB,SAAS,EACT,YAAY,EACZ,kBAAkB,GAClB,MAAM,gBAAgB,CAAA;AAGvB,OAAO,EACN,cAAc,EACd,sBAAsB,EACtB,oBAAoB,EACpB,iBAAiB,EACjB,uBAAuB,EACvB,6BAA6B,EAC7B,IAAI,GACJ,MAAM,sBAAsB,CAAA;AAE7B,YAAY,EACX,QAAQ,EACR,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,cAAc,EACd,UAAU,EACV,WAAW,EACX,UAAU,EACV,UAAU,EACV,WAAW,EACX,sBAAsB,EACtB,YAAY,EACZ,aAAa,EACb,iBAAiB,EACjB,iBAAiB,EACjB,uBAAuB,EACvB,2BAA2B,EAC3B,kBAAkB,EAClB,eAAe,GACf,MAAM,sBAAsB,CAAA;AAG7B,OAAO,EACN,OAAO,EACP,UAAU,EACV,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EAEjB,gBAAgB,EAChB,eAAe,EACf,qBAAqB,EAErB,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAEN,WAAW,EAEX,EAAE,EACF,GAAG,EACH,IAAI,EACJ,KAAK,EACL,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,YAAY,EAEZ,YAAY,EACZ,YAAY,EAEZ,YAAY,EAEZ,GAAG,EACH,SAAS,EACT,OAAO,EAEP,UAAU,EACV,eAAe,EACf,WAAW,EACX,KAAK,EACL,KAAK,EAEL,eAAe,EAEf,cAAc,EAEd,WAAW,EACX,oBAAoB,EAEpB,oBAAoB,EAEpB,WAAW,EACX,eAAe,EAEf,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,aAAa,EAEb,qBAAqB,GACrB,MAAM,iBAAiB,CAAA;AAExB,YAAY,EAEX,IAAI,EACJ,WAAW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a,EACb,UAAU,EACV,eAAe,EACf,QAAQ,EACR,aAAa,EACb,gBAAgB,EAChB,UAAU,EACV,cAAc,EACd,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,WAAW,EACX,cAAc,EACd,YAAY,EAEZ,WAAW,EACX,oBAAoB,EACpB,YAAY,EACZ,cAAc,EAEd,aAAa,EACb,aAAa,EACb,mBAAmB,EAEnB,gBAAgB,EAChB,aAAa,EACb,UAAU,EACV,0BAA0B,EAC1B,kBAAkB,EAElB,cAAc,EACd,WAAW,EACX,oBAAoB,EACpB,aAAa,EACb,WAAW,EACX,oBAAoB,EACpB,aAAa,EAEb,YAAY,EACZ,WAAW,EAEX,aAAa,EACb,eAAe,EACf,mBAAmB,EACnB,eAAe,GACf,MAAM,oBAAoB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -8630,94 +8630,6 @@ function computeRelevance(input, output) {
|
|
|
8630
8630
|
};
|
|
8631
8631
|
}
|
|
8632
8632
|
|
|
8633
|
-
// ../agents/src/identity.ts
|
|
8634
|
-
import { createHash as createHash3, createHmac, randomBytes as randomBytes2, timingSafeEqual } from "node:crypto";
|
|
8635
|
-
var DEFAULT_REPLAY_WINDOW_MS = 5 * 60 * 1000;
|
|
8636
|
-
function createAgentIdentity(config) {
|
|
8637
|
-
const secret = config.secret ?? randomBytes2(32).toString("hex");
|
|
8638
|
-
const replayWindowMs = config.replayWindowMs ?? DEFAULT_REPLAY_WINDOW_MS;
|
|
8639
|
-
const publicKey = createHash3("sha256").update(secret).digest("hex");
|
|
8640
|
-
const usedNonces = new Set;
|
|
8641
|
-
let lastCleanup = Date.now();
|
|
8642
|
-
function cleanupNonces() {
|
|
8643
|
-
const now = Date.now();
|
|
8644
|
-
if (now - lastCleanup < replayWindowMs)
|
|
8645
|
-
return;
|
|
8646
|
-
usedNonces.clear();
|
|
8647
|
-
lastCleanup = now;
|
|
8648
|
-
}
|
|
8649
|
-
function computeSignature(payload, timestamp, nonce) {
|
|
8650
|
-
const content = JSON.stringify({ payload, agentId: config.agentId, timestamp, nonce });
|
|
8651
|
-
return createHmac("sha256", secret).update(content).digest("hex");
|
|
8652
|
-
}
|
|
8653
|
-
return {
|
|
8654
|
-
get agentId() {
|
|
8655
|
-
return config.agentId;
|
|
8656
|
-
},
|
|
8657
|
-
get publicKey() {
|
|
8658
|
-
return publicKey;
|
|
8659
|
-
},
|
|
8660
|
-
sign(payload) {
|
|
8661
|
-
const timestamp = Date.now();
|
|
8662
|
-
const nonce = randomBytes2(16).toString("hex");
|
|
8663
|
-
const signature = computeSignature(payload, timestamp, nonce);
|
|
8664
|
-
return {
|
|
8665
|
-
payload,
|
|
8666
|
-
signature,
|
|
8667
|
-
agentId: config.agentId,
|
|
8668
|
-
timestamp,
|
|
8669
|
-
nonce
|
|
8670
|
-
};
|
|
8671
|
-
},
|
|
8672
|
-
verify(signed) {
|
|
8673
|
-
if (signed.agentId !== config.agentId) {
|
|
8674
|
-
return { valid: false, reason: "Agent ID mismatch" };
|
|
8675
|
-
}
|
|
8676
|
-
const now = Date.now();
|
|
8677
|
-
const age = now - signed.timestamp;
|
|
8678
|
-
if (age > replayWindowMs || age < -replayWindowMs) {
|
|
8679
|
-
return { valid: false, reason: "Timestamp outside replay window" };
|
|
8680
|
-
}
|
|
8681
|
-
cleanupNonces();
|
|
8682
|
-
if (usedNonces.has(signed.nonce)) {
|
|
8683
|
-
return { valid: false, reason: "Nonce already used (replay attack)" };
|
|
8684
|
-
}
|
|
8685
|
-
const expected = computeSignature(signed.payload, signed.timestamp, signed.nonce);
|
|
8686
|
-
const sigBuf = Buffer.from(signed.signature, "hex");
|
|
8687
|
-
const expectedBuf = Buffer.from(expected, "hex");
|
|
8688
|
-
if (sigBuf.length !== expectedBuf.length) {
|
|
8689
|
-
return { valid: false, reason: "Invalid signature" };
|
|
8690
|
-
}
|
|
8691
|
-
if (!timingSafeEqual(sigBuf, expectedBuf)) {
|
|
8692
|
-
return { valid: false, reason: "Invalid signature" };
|
|
8693
|
-
}
|
|
8694
|
-
usedNonces.add(signed.nonce);
|
|
8695
|
-
return { valid: true };
|
|
8696
|
-
}
|
|
8697
|
-
};
|
|
8698
|
-
}
|
|
8699
|
-
function createIdentityRegistry() {
|
|
8700
|
-
const identities = new Map;
|
|
8701
|
-
return {
|
|
8702
|
-
register(identity) {
|
|
8703
|
-
identities.set(identity.agentId, identity);
|
|
8704
|
-
},
|
|
8705
|
-
get(agentId) {
|
|
8706
|
-
return identities.get(agentId);
|
|
8707
|
-
},
|
|
8708
|
-
verifySignedPayload(signed) {
|
|
8709
|
-
const identity = identities.get(signed.agentId);
|
|
8710
|
-
if (!identity) {
|
|
8711
|
-
return { valid: false, reason: `Unknown agent: ${signed.agentId}` };
|
|
8712
|
-
}
|
|
8713
|
-
return identity.verify(signed);
|
|
8714
|
-
},
|
|
8715
|
-
get agents() {
|
|
8716
|
-
return [...identities.keys()];
|
|
8717
|
-
}
|
|
8718
|
-
};
|
|
8719
|
-
}
|
|
8720
|
-
|
|
8721
8633
|
// ../agents/src/memory.ts
|
|
8722
8634
|
function createMemory(config) {
|
|
8723
8635
|
const messages = [];
|
|
@@ -9755,11 +9667,8 @@ function resolveDependencies(config, deps) {
|
|
|
9755
9667
|
stream: (req) => gw.stream(req)
|
|
9756
9668
|
};
|
|
9757
9669
|
}
|
|
9758
|
-
function
|
|
9759
|
-
|
|
9760
|
-
const memory = createMemory(config.memory ?? { strategy: "sliding-window", maxMessages: 50 });
|
|
9761
|
-
const toolMap = new Map((config.tools ?? []).map((t) => [t.name, t]));
|
|
9762
|
-
const guardrails = {
|
|
9670
|
+
function resolveGuardrails(config) {
|
|
9671
|
+
return {
|
|
9763
9672
|
maxIterations: config.guardrails?.maxIterations ?? 10,
|
|
9764
9673
|
maxTokenBudget: config.guardrails?.maxTokenBudget ?? 500000,
|
|
9765
9674
|
maxDurationMs: config.guardrails?.maxDurationMs ?? 0,
|
|
@@ -9769,11 +9678,16 @@ function defineAgent(config, deps) {
|
|
|
9769
9678
|
security: config.guardrails?.security,
|
|
9770
9679
|
runtimePolicy: config.guardrails?.runtimePolicy
|
|
9771
9680
|
};
|
|
9681
|
+
}
|
|
9682
|
+
function defineAgent(config, deps) {
|
|
9683
|
+
const resolvedDeps = resolveDependencies(config, deps);
|
|
9684
|
+
const memory = createMemory(config.memory ?? { strategy: "sliding-window", maxMessages: 50 });
|
|
9685
|
+
const toolMap = new Map((config.tools ?? []).map((t) => [t.name, t]));
|
|
9686
|
+
const guardrails = resolveGuardrails(config);
|
|
9772
9687
|
const semanticValidator = guardrails.semantic ? createSemanticValidator(guardrails.semantic, resolvedDeps.complete) : null;
|
|
9773
9688
|
const agentSecurity = guardrails.security ? createAgentSecurity(guardrails.security) : null;
|
|
9774
9689
|
const approvalGate = config.guardrails?.approval ? createApprovalGate(config.guardrails.approval) : null;
|
|
9775
9690
|
const runtimePolicy = guardrails.runtimePolicy ? createRuntimePolicyEnforcer(guardrails.runtimePolicy) : null;
|
|
9776
|
-
const identity = config.identity ? createAgentIdentity(config.identity) : null;
|
|
9777
9691
|
const maxDurationMs = config.guardrails?.maxDurationMs ?? 0;
|
|
9778
9692
|
const confidenceScorer = config.confidence ? createConfidenceScorer(typeof config.confidence === "boolean" ? {} : config.confidence) : null;
|
|
9779
9693
|
function formatFailedChecks(checks) {
|
|
@@ -9955,53 +9869,58 @@ function defineAgent(config, deps) {
|
|
|
9955
9869
|
metadata: { iterations, maxIterations: guardrails.maxIterations }
|
|
9956
9870
|
});
|
|
9957
9871
|
}
|
|
9872
|
+
async function checkApprovalGate(tc) {
|
|
9873
|
+
if (!approvalGate)
|
|
9874
|
+
return null;
|
|
9875
|
+
if (!shouldRequireApproval(config.guardrails?.approval?.requireApprovalFor, {
|
|
9876
|
+
toolName: tc.name
|
|
9877
|
+
}))
|
|
9878
|
+
return null;
|
|
9879
|
+
const decision = await approvalGate.requestApproval("tool_call", `Execute tool: ${tc.name}`, {
|
|
9880
|
+
toolName: tc.name,
|
|
9881
|
+
arguments: tc.arguments
|
|
9882
|
+
});
|
|
9883
|
+
if (decision.approved)
|
|
9884
|
+
return null;
|
|
9885
|
+
return {
|
|
9886
|
+
success: false,
|
|
9887
|
+
error: `Tool call denied: ${decision.reason ?? "Approval denied"}`,
|
|
9888
|
+
toolCallId: tc.id,
|
|
9889
|
+
durationMs: 0
|
|
9890
|
+
};
|
|
9891
|
+
}
|
|
9892
|
+
function checkRuntimePolicy(tc, options) {
|
|
9893
|
+
if (!runtimePolicy)
|
|
9894
|
+
return;
|
|
9895
|
+
runtimePolicy.evaluateToolCall({
|
|
9896
|
+
toolName: tc.name,
|
|
9897
|
+
toolArguments: tc.arguments,
|
|
9898
|
+
model: config.model,
|
|
9899
|
+
actor: options.metadata?.actor,
|
|
9900
|
+
role: options.metadata?.role
|
|
9901
|
+
});
|
|
9902
|
+
}
|
|
9903
|
+
async function executeSingleToolCall(tc, options) {
|
|
9904
|
+
const denied = await checkApprovalGate(tc);
|
|
9905
|
+
if (denied)
|
|
9906
|
+
return denied;
|
|
9907
|
+
checkRuntimePolicy(tc, options);
|
|
9908
|
+
const tool = toolMap.get(tc.name);
|
|
9909
|
+
if (!tool) {
|
|
9910
|
+
return {
|
|
9911
|
+
success: false,
|
|
9912
|
+
error: `Unknown tool: ${tc.name}. Available: ${Array.from(toolMap.keys()).join(", ")}`,
|
|
9913
|
+
toolCallId: tc.id,
|
|
9914
|
+
durationMs: 0
|
|
9915
|
+
};
|
|
9916
|
+
}
|
|
9917
|
+
return tool.execute(tc.arguments, { toolCallId: tc.id, signal: options.signal });
|
|
9918
|
+
}
|
|
9958
9919
|
async function executeToolCalls2(toolCalls, history, options = {}) {
|
|
9959
9920
|
const results = [];
|
|
9960
9921
|
for (const tc of toolCalls) {
|
|
9961
9922
|
await safeHook2(() => config.hooks?.onToolCall?.({ name: tc.name, arguments: tc.arguments }));
|
|
9962
|
-
|
|
9963
|
-
toolName: tc.name
|
|
9964
|
-
})) {
|
|
9965
|
-
const decision = await approvalGate.requestApproval("tool_call", `Execute tool: ${tc.name}`, { toolName: tc.name, arguments: tc.arguments });
|
|
9966
|
-
if (!decision.approved) {
|
|
9967
|
-
const deniedResult = {
|
|
9968
|
-
success: false,
|
|
9969
|
-
error: `Tool call denied: ${decision.reason ?? "Approval denied"}`,
|
|
9970
|
-
toolCallId: tc.id,
|
|
9971
|
-
durationMs: 0
|
|
9972
|
-
};
|
|
9973
|
-
await safeHook2(() => config.hooks?.onToolResult?.(deniedResult));
|
|
9974
|
-
history.push({ name: tc.name, arguments: tc.arguments, result: deniedResult });
|
|
9975
|
-
results.push(formatToolResult(deniedResult));
|
|
9976
|
-
continue;
|
|
9977
|
-
}
|
|
9978
|
-
}
|
|
9979
|
-
if (runtimePolicy) {
|
|
9980
|
-
runtimePolicy.evaluateToolCall({
|
|
9981
|
-
toolName: tc.name,
|
|
9982
|
-
toolArguments: tc.arguments,
|
|
9983
|
-
model: config.model,
|
|
9984
|
-
actor: options.metadata?.actor,
|
|
9985
|
-
role: options.metadata?.role
|
|
9986
|
-
});
|
|
9987
|
-
}
|
|
9988
|
-
const tool = toolMap.get(tc.name);
|
|
9989
|
-
if (!tool) {
|
|
9990
|
-
const errorResult = {
|
|
9991
|
-
success: false,
|
|
9992
|
-
error: `Unknown tool: ${tc.name}. Available: ${Array.from(toolMap.keys()).join(", ")}`,
|
|
9993
|
-
toolCallId: tc.id,
|
|
9994
|
-
durationMs: 0
|
|
9995
|
-
};
|
|
9996
|
-
await safeHook2(() => config.hooks?.onToolResult?.(errorResult));
|
|
9997
|
-
history.push({ name: tc.name, arguments: tc.arguments, result: errorResult });
|
|
9998
|
-
results.push(formatToolResult(errorResult));
|
|
9999
|
-
continue;
|
|
10000
|
-
}
|
|
10001
|
-
const result = await tool.execute(tc.arguments, {
|
|
10002
|
-
toolCallId: tc.id,
|
|
10003
|
-
signal: options.signal
|
|
10004
|
-
});
|
|
9923
|
+
const result = await executeSingleToolCall(tc, options);
|
|
10005
9924
|
await safeHook2(() => config.hooks?.onToolResult?.(result));
|
|
10006
9925
|
history.push({ name: tc.name, arguments: tc.arguments, result });
|
|
10007
9926
|
results.push(formatToolResult(result));
|
|
@@ -10181,7 +10100,7 @@ function createSqliteMemoryStore(config) {
|
|
|
10181
10100
|
};
|
|
10182
10101
|
}
|
|
10183
10102
|
// ../agents/src/stores/integrity.ts
|
|
10184
|
-
import { createHash as
|
|
10103
|
+
import { createHash as createHash3 } from "node:crypto";
|
|
10185
10104
|
var ZERO_HASH = "0".repeat(64);
|
|
10186
10105
|
function computeMessageHash(message, index, previousHash) {
|
|
10187
10106
|
const content = JSON.stringify({
|
|
@@ -10190,7 +10109,7 @@ function computeMessageHash(message, index, previousHash) {
|
|
|
10190
10109
|
index,
|
|
10191
10110
|
previousHash
|
|
10192
10111
|
});
|
|
10193
|
-
return
|
|
10112
|
+
return createHash3("sha256").update(content).digest("hex");
|
|
10194
10113
|
}
|
|
10195
10114
|
function verifyMessageChain(messages, hashes) {
|
|
10196
10115
|
if (messages.length === 0) {
|
|
@@ -10248,6 +10167,106 @@ function createSecureMemoryStore(inner) {
|
|
|
10248
10167
|
}
|
|
10249
10168
|
};
|
|
10250
10169
|
}
|
|
10170
|
+
// ../agents/src/stores/task-store.ts
|
|
10171
|
+
import { mkdir, readFile, readdir, rename, unlink, writeFile } from "node:fs/promises";
|
|
10172
|
+
import { join } from "node:path";
|
|
10173
|
+
function createInMemoryTaskStore() {
|
|
10174
|
+
const store = new Map;
|
|
10175
|
+
return {
|
|
10176
|
+
async save(task) {
|
|
10177
|
+
store.set(task.id, structuredClone(task));
|
|
10178
|
+
},
|
|
10179
|
+
async load(taskId) {
|
|
10180
|
+
const task = store.get(taskId);
|
|
10181
|
+
return task ? structuredClone(task) : null;
|
|
10182
|
+
},
|
|
10183
|
+
async list(filter) {
|
|
10184
|
+
const all = [...store.values()].map((t) => structuredClone(t));
|
|
10185
|
+
return filter?.status ? all.filter((t) => t.status === filter.status) : all;
|
|
10186
|
+
},
|
|
10187
|
+
async delete(taskId) {
|
|
10188
|
+
store.delete(taskId);
|
|
10189
|
+
}
|
|
10190
|
+
};
|
|
10191
|
+
}
|
|
10192
|
+
var TASK_ID_PATTERN = /^[a-zA-Z0-9_-]+$/;
|
|
10193
|
+
function assertSafeTaskId(taskId) {
|
|
10194
|
+
if (!TASK_ID_PATTERN.test(taskId)) {
|
|
10195
|
+
throw new Error(`Invalid task id format: ${taskId}`);
|
|
10196
|
+
}
|
|
10197
|
+
}
|
|
10198
|
+
function createJsonFileTaskStore(config) {
|
|
10199
|
+
const { dir } = config;
|
|
10200
|
+
let initialized = false;
|
|
10201
|
+
let initPromise = null;
|
|
10202
|
+
async function ensureDir() {
|
|
10203
|
+
if (initialized)
|
|
10204
|
+
return;
|
|
10205
|
+
if (initPromise)
|
|
10206
|
+
return initPromise;
|
|
10207
|
+
initPromise = mkdir(dir, { recursive: true }).then(() => {
|
|
10208
|
+
initialized = true;
|
|
10209
|
+
});
|
|
10210
|
+
return initPromise;
|
|
10211
|
+
}
|
|
10212
|
+
function pathFor(taskId) {
|
|
10213
|
+
assertSafeTaskId(taskId);
|
|
10214
|
+
return join(dir, `${taskId}.json`);
|
|
10215
|
+
}
|
|
10216
|
+
async function readDirSafe() {
|
|
10217
|
+
try {
|
|
10218
|
+
await ensureDir();
|
|
10219
|
+
return await readdir(dir);
|
|
10220
|
+
} catch (err2) {
|
|
10221
|
+
if (err2.code === "ENOENT")
|
|
10222
|
+
return [];
|
|
10223
|
+
throw err2;
|
|
10224
|
+
}
|
|
10225
|
+
}
|
|
10226
|
+
async function readTaskFile(path) {
|
|
10227
|
+
try {
|
|
10228
|
+
const raw = await readFile(path, "utf8");
|
|
10229
|
+
return JSON.parse(raw);
|
|
10230
|
+
} catch {
|
|
10231
|
+
return null;
|
|
10232
|
+
}
|
|
10233
|
+
}
|
|
10234
|
+
return {
|
|
10235
|
+
async save(task) {
|
|
10236
|
+
await ensureDir();
|
|
10237
|
+
const path = pathFor(task.id);
|
|
10238
|
+
const tmp = `${path}.tmp`;
|
|
10239
|
+
await writeFile(tmp, JSON.stringify(task), "utf8");
|
|
10240
|
+
await rename(tmp, path);
|
|
10241
|
+
},
|
|
10242
|
+
async load(taskId) {
|
|
10243
|
+
try {
|
|
10244
|
+
const path = pathFor(taskId);
|
|
10245
|
+
const raw = await readFile(path, "utf8");
|
|
10246
|
+
return JSON.parse(raw);
|
|
10247
|
+
} catch (err2) {
|
|
10248
|
+
if (err2.code === "ENOENT")
|
|
10249
|
+
return null;
|
|
10250
|
+
throw err2;
|
|
10251
|
+
}
|
|
10252
|
+
},
|
|
10253
|
+
async list(filter) {
|
|
10254
|
+
const files = await readDirSafe();
|
|
10255
|
+
const candidates = files.filter((f) => f.endsWith(".json") && !f.endsWith(".tmp"));
|
|
10256
|
+
const loaded = await Promise.all(candidates.map((f) => readTaskFile(join(dir, f))));
|
|
10257
|
+
const tasks = loaded.filter((t) => t !== null);
|
|
10258
|
+
return filter?.status ? tasks.filter((t) => t.status === filter.status) : tasks;
|
|
10259
|
+
},
|
|
10260
|
+
async delete(taskId) {
|
|
10261
|
+
try {
|
|
10262
|
+
await unlink(pathFor(taskId));
|
|
10263
|
+
} catch (err2) {
|
|
10264
|
+
if (err2.code !== "ENOENT")
|
|
10265
|
+
throw err2;
|
|
10266
|
+
}
|
|
10267
|
+
}
|
|
10268
|
+
};
|
|
10269
|
+
}
|
|
10251
10270
|
// ../agents/src/shared-memory.ts
|
|
10252
10271
|
function createSharedMemory() {
|
|
10253
10272
|
const store = new Map;
|
|
@@ -10492,6 +10511,7 @@ function createInMemoryThreadStore() {
|
|
|
10492
10511
|
};
|
|
10493
10512
|
}
|
|
10494
10513
|
// ../agents/src/async-agent.ts
|
|
10514
|
+
var log8 = createLogger();
|
|
10495
10515
|
function createAsyncAgent(config) {
|
|
10496
10516
|
const tasks = new Map;
|
|
10497
10517
|
function emitProgress(task, event) {
|
|
@@ -10499,6 +10519,33 @@ function createAsyncAgent(config) {
|
|
|
10499
10519
|
config.onProgress?.(toPublicTask(task), event);
|
|
10500
10520
|
} catch {}
|
|
10501
10521
|
}
|
|
10522
|
+
function toPersistedTask(task) {
|
|
10523
|
+
return {
|
|
10524
|
+
id: task.id,
|
|
10525
|
+
agentName: task.agentName,
|
|
10526
|
+
input: task.input,
|
|
10527
|
+
status: task.status,
|
|
10528
|
+
result: task.result,
|
|
10529
|
+
error: task.error ? { message: task.error.message, stack: task.error.stack } : null,
|
|
10530
|
+
createdAt: task.createdAt,
|
|
10531
|
+
startedAt: task.startedAt,
|
|
10532
|
+
completedAt: task.completedAt,
|
|
10533
|
+
metadata: task.metadata
|
|
10534
|
+
};
|
|
10535
|
+
}
|
|
10536
|
+
function persistTask(task) {
|
|
10537
|
+
if (!config.taskStore)
|
|
10538
|
+
return;
|
|
10539
|
+
const store = config.taskStore;
|
|
10540
|
+
const snapshot = toPersistedTask(task);
|
|
10541
|
+
store.save(snapshot).catch((err2) => {
|
|
10542
|
+
log8.warn("async agent task persistence failed", {
|
|
10543
|
+
taskId: task.id,
|
|
10544
|
+
status: task.status,
|
|
10545
|
+
error: err2 instanceof Error ? err2.message : String(err2)
|
|
10546
|
+
});
|
|
10547
|
+
});
|
|
10548
|
+
}
|
|
10502
10549
|
function toPublicTask(task) {
|
|
10503
10550
|
return {
|
|
10504
10551
|
id: task.id,
|
|
@@ -10517,6 +10564,7 @@ function createAsyncAgent(config) {
|
|
|
10517
10564
|
task.completedAt = Date.now();
|
|
10518
10565
|
task.abortController.abort();
|
|
10519
10566
|
emitProgress(task, { type: "cancelled", taskId: task.id });
|
|
10567
|
+
persistTask(task);
|
|
10520
10568
|
task.reject(new ElsiumError({
|
|
10521
10569
|
code: "VALIDATION_ERROR",
|
|
10522
10570
|
message: `Task ${task.id} was cancelled`,
|
|
@@ -10533,6 +10581,7 @@ function createAsyncAgent(config) {
|
|
|
10533
10581
|
task.status = "running";
|
|
10534
10582
|
task.startedAt = Date.now();
|
|
10535
10583
|
emitProgress(task, { type: "started", taskId: task.id });
|
|
10584
|
+
persistTask(task);
|
|
10536
10585
|
try {
|
|
10537
10586
|
const result = await config.agent.run(task.input, {
|
|
10538
10587
|
signal: task.abortController.signal,
|
|
@@ -10544,6 +10593,7 @@ function createAsyncAgent(config) {
|
|
|
10544
10593
|
task.result = result;
|
|
10545
10594
|
task.completedAt = Date.now();
|
|
10546
10595
|
emitProgress(task, { type: "completed", taskId: task.id, result });
|
|
10596
|
+
persistTask(task);
|
|
10547
10597
|
try {
|
|
10548
10598
|
config.onComplete?.(toPublicTask(task));
|
|
10549
10599
|
} catch {}
|
|
@@ -10556,6 +10606,7 @@ function createAsyncAgent(config) {
|
|
|
10556
10606
|
task.error = error;
|
|
10557
10607
|
task.completedAt = Date.now();
|
|
10558
10608
|
emitProgress(task, { type: "failed", taskId: task.id, error });
|
|
10609
|
+
persistTask(task);
|
|
10559
10610
|
try {
|
|
10560
10611
|
config.onError?.(toPublicTask(task), error);
|
|
10561
10612
|
} catch {}
|
|
@@ -10592,6 +10643,7 @@ function createAsyncAgent(config) {
|
|
|
10592
10643
|
reject: rejectPromise
|
|
10593
10644
|
};
|
|
10594
10645
|
tasks.set(taskId, task);
|
|
10646
|
+
persistTask(task);
|
|
10595
10647
|
executeTask(task);
|
|
10596
10648
|
return toPublicTask(task);
|
|
10597
10649
|
},
|
|
@@ -10611,6 +10663,7 @@ function createAsyncAgent(config) {
|
|
|
10611
10663
|
task.completedAt = Date.now();
|
|
10612
10664
|
task.abortController.abort();
|
|
10613
10665
|
emitProgress(task, { type: "cancelled", taskId: task.id });
|
|
10666
|
+
persistTask(task);
|
|
10614
10667
|
task.reject(new ElsiumError({
|
|
10615
10668
|
code: "VALIDATION_ERROR",
|
|
10616
10669
|
message: `Task ${task.id} was cancelled`,
|
|
@@ -10618,6 +10671,24 @@ function createAsyncAgent(config) {
|
|
|
10618
10671
|
}));
|
|
10619
10672
|
}
|
|
10620
10673
|
}
|
|
10674
|
+
},
|
|
10675
|
+
async recover() {
|
|
10676
|
+
if (!config.taskStore)
|
|
10677
|
+
return [];
|
|
10678
|
+
const store = config.taskStore;
|
|
10679
|
+
const [pending, running] = await Promise.all([
|
|
10680
|
+
store.list({ status: "pending" }),
|
|
10681
|
+
store.list({ status: "running" })
|
|
10682
|
+
]);
|
|
10683
|
+
const orphans = [...pending, ...running];
|
|
10684
|
+
const now = Date.now();
|
|
10685
|
+
await Promise.all(orphans.map((orphan) => store.save({
|
|
10686
|
+
...orphan,
|
|
10687
|
+
status: "failed",
|
|
10688
|
+
completedAt: now,
|
|
10689
|
+
error: { message: "Process restart: task did not complete" }
|
|
10690
|
+
})));
|
|
10691
|
+
return orphans;
|
|
10621
10692
|
}
|
|
10622
10693
|
};
|
|
10623
10694
|
}
|
|
@@ -11283,6 +11354,93 @@ function createScheduler(config) {
|
|
|
11283
11354
|
}
|
|
11284
11355
|
};
|
|
11285
11356
|
}
|
|
11357
|
+
// ../agents/src/identity.ts
|
|
11358
|
+
import { createHash as createHash4, createHmac, randomBytes as randomBytes2, timingSafeEqual } from "node:crypto";
|
|
11359
|
+
var DEFAULT_REPLAY_WINDOW_MS = 5 * 60 * 1000;
|
|
11360
|
+
function createAgentIdentity(config) {
|
|
11361
|
+
const secret = config.secret ?? randomBytes2(32).toString("hex");
|
|
11362
|
+
const replayWindowMs = config.replayWindowMs ?? DEFAULT_REPLAY_WINDOW_MS;
|
|
11363
|
+
const publicKey = createHash4("sha256").update(secret).digest("hex");
|
|
11364
|
+
const usedNonces = new Set;
|
|
11365
|
+
let lastCleanup = Date.now();
|
|
11366
|
+
function cleanupNonces() {
|
|
11367
|
+
const now = Date.now();
|
|
11368
|
+
if (now - lastCleanup < replayWindowMs)
|
|
11369
|
+
return;
|
|
11370
|
+
usedNonces.clear();
|
|
11371
|
+
lastCleanup = now;
|
|
11372
|
+
}
|
|
11373
|
+
function computeSignature(payload, timestamp, nonce) {
|
|
11374
|
+
const content = JSON.stringify({ payload, agentId: config.agentId, timestamp, nonce });
|
|
11375
|
+
return createHmac("sha256", secret).update(content).digest("hex");
|
|
11376
|
+
}
|
|
11377
|
+
return {
|
|
11378
|
+
get agentId() {
|
|
11379
|
+
return config.agentId;
|
|
11380
|
+
},
|
|
11381
|
+
get publicKey() {
|
|
11382
|
+
return publicKey;
|
|
11383
|
+
},
|
|
11384
|
+
sign(payload) {
|
|
11385
|
+
const timestamp = Date.now();
|
|
11386
|
+
const nonce = randomBytes2(16).toString("hex");
|
|
11387
|
+
const signature = computeSignature(payload, timestamp, nonce);
|
|
11388
|
+
return {
|
|
11389
|
+
payload,
|
|
11390
|
+
signature,
|
|
11391
|
+
agentId: config.agentId,
|
|
11392
|
+
timestamp,
|
|
11393
|
+
nonce
|
|
11394
|
+
};
|
|
11395
|
+
},
|
|
11396
|
+
verify(signed) {
|
|
11397
|
+
if (signed.agentId !== config.agentId) {
|
|
11398
|
+
return { valid: false, reason: "Agent ID mismatch" };
|
|
11399
|
+
}
|
|
11400
|
+
const now = Date.now();
|
|
11401
|
+
const age = now - signed.timestamp;
|
|
11402
|
+
if (age > replayWindowMs || age < -replayWindowMs) {
|
|
11403
|
+
return { valid: false, reason: "Timestamp outside replay window" };
|
|
11404
|
+
}
|
|
11405
|
+
cleanupNonces();
|
|
11406
|
+
if (usedNonces.has(signed.nonce)) {
|
|
11407
|
+
return { valid: false, reason: "Nonce already used (replay attack)" };
|
|
11408
|
+
}
|
|
11409
|
+
const expected = computeSignature(signed.payload, signed.timestamp, signed.nonce);
|
|
11410
|
+
const sigBuf = Buffer.from(signed.signature, "hex");
|
|
11411
|
+
const expectedBuf = Buffer.from(expected, "hex");
|
|
11412
|
+
if (sigBuf.length !== expectedBuf.length) {
|
|
11413
|
+
return { valid: false, reason: "Invalid signature" };
|
|
11414
|
+
}
|
|
11415
|
+
if (!timingSafeEqual(sigBuf, expectedBuf)) {
|
|
11416
|
+
return { valid: false, reason: "Invalid signature" };
|
|
11417
|
+
}
|
|
11418
|
+
usedNonces.add(signed.nonce);
|
|
11419
|
+
return { valid: true };
|
|
11420
|
+
}
|
|
11421
|
+
};
|
|
11422
|
+
}
|
|
11423
|
+
function createIdentityRegistry() {
|
|
11424
|
+
const identities = new Map;
|
|
11425
|
+
return {
|
|
11426
|
+
register(identity) {
|
|
11427
|
+
identities.set(identity.agentId, identity);
|
|
11428
|
+
},
|
|
11429
|
+
get(agentId) {
|
|
11430
|
+
return identities.get(agentId);
|
|
11431
|
+
},
|
|
11432
|
+
verifySignedPayload(signed) {
|
|
11433
|
+
const identity = identities.get(signed.agentId);
|
|
11434
|
+
if (!identity) {
|
|
11435
|
+
return { valid: false, reason: `Unknown agent: ${signed.agentId}` };
|
|
11436
|
+
}
|
|
11437
|
+
return identity.verify(signed);
|
|
11438
|
+
},
|
|
11439
|
+
get agents() {
|
|
11440
|
+
return [...identities.keys()];
|
|
11441
|
+
}
|
|
11442
|
+
};
|
|
11443
|
+
}
|
|
11286
11444
|
// ../rag/src/loaders.ts
|
|
11287
11445
|
function createDocument(content, metadata) {
|
|
11288
11446
|
return {
|
|
@@ -11946,7 +12104,7 @@ function rag(config) {
|
|
|
11946
12104
|
// ../rag/src/stores/pgvector.ts
|
|
11947
12105
|
import { createRequire as createRequire2 } from "node:module";
|
|
11948
12106
|
var require3 = createRequire2(import.meta.url);
|
|
11949
|
-
var
|
|
12107
|
+
var log9 = createLogger();
|
|
11950
12108
|
var BLOCKED_KEYS3 = new Set(["__proto__", "constructor", "prototype"]);
|
|
11951
12109
|
var TABLE_NAME_PATTERN2 = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
|
|
11952
12110
|
function createPgVectorStore(config) {
|
|
@@ -11982,7 +12140,7 @@ function createPgVectorStore(config) {
|
|
|
11982
12140
|
}
|
|
11983
12141
|
return client;
|
|
11984
12142
|
} catch (err2) {
|
|
11985
|
-
|
|
12143
|
+
log9.error("Failed to initialize PgVector store", {
|
|
11986
12144
|
error: err2 instanceof Error ? err2.message : String(err2)
|
|
11987
12145
|
});
|
|
11988
12146
|
throw new Error("pg is required for PgVector store. Install it as a dependency.");
|
|
@@ -13257,7 +13415,7 @@ function createCostEngine(config = {}) {
|
|
|
13257
13415
|
}
|
|
13258
13416
|
// ../observe/src/tracer.ts
|
|
13259
13417
|
import { writeFileSync } from "node:fs";
|
|
13260
|
-
var
|
|
13418
|
+
var log10 = createLogger();
|
|
13261
13419
|
function observe(config = {}) {
|
|
13262
13420
|
const {
|
|
13263
13421
|
output = ["console"],
|
|
@@ -13280,7 +13438,7 @@ function observe(config = {}) {
|
|
|
13280
13438
|
try {
|
|
13281
13439
|
writeFileSync(filename, JSON.stringify(spansToExport, null, 2));
|
|
13282
13440
|
} catch (err2) {
|
|
13283
|
-
|
|
13441
|
+
log10.error("Failed to write trace file", {
|
|
13284
13442
|
error: err2 instanceof Error ? err2.message : String(err2)
|
|
13285
13443
|
});
|
|
13286
13444
|
}
|
|
@@ -13355,7 +13513,7 @@ function observe(config = {}) {
|
|
|
13355
13513
|
function consoleHandler(span) {
|
|
13356
13514
|
const duration = span.durationMs !== undefined ? `${span.durationMs}ms` : "running";
|
|
13357
13515
|
const status = span.status === "error" ? "[ERROR]" : span.status === "ok" ? "[OK]" : "[...]";
|
|
13358
|
-
|
|
13516
|
+
log10.info("span", {
|
|
13359
13517
|
trace: span.traceId,
|
|
13360
13518
|
span: span.name,
|
|
13361
13519
|
kind: span.kind,
|
|
@@ -13457,7 +13615,7 @@ function createMetrics(options) {
|
|
|
13457
13615
|
import { createHash as createHash5 } from "node:crypto";
|
|
13458
13616
|
|
|
13459
13617
|
// ../observe/src/audit-sink.ts
|
|
13460
|
-
var
|
|
13618
|
+
var log11 = createLogger();
|
|
13461
13619
|
function getRetryDelay2(attempt, baseDelayMs, maxDelayMs) {
|
|
13462
13620
|
const delay = Math.min(baseDelayMs * 2 ** attempt, maxDelayMs);
|
|
13463
13621
|
return delay * (0.5 + Math.random() * 0.5);
|
|
@@ -13485,14 +13643,14 @@ async function deliverToSink(sink, events, retryConfig, deadLetterSink, onError)
|
|
|
13485
13643
|
try {
|
|
13486
13644
|
await sendWithRetry(sink, filtered, retryConfig);
|
|
13487
13645
|
} catch (error) {
|
|
13488
|
-
|
|
13646
|
+
log11.error("Audit sink delivery failed", { sink: sink.name });
|
|
13489
13647
|
onError?.(sink.name, error);
|
|
13490
13648
|
if (!deadLetterSink)
|
|
13491
13649
|
return;
|
|
13492
13650
|
try {
|
|
13493
13651
|
await deadLetterSink.send(filtered);
|
|
13494
13652
|
} catch (dlqError) {
|
|
13495
|
-
|
|
13653
|
+
log11.error("Dead letter sink delivery failed", { sink: deadLetterSink.name });
|
|
13496
13654
|
onError?.(deadLetterSink.name, dlqError);
|
|
13497
13655
|
}
|
|
13498
13656
|
}
|
|
@@ -13536,7 +13694,7 @@ function createSinkManager(config) {
|
|
|
13536
13694
|
dispatch(event) {
|
|
13537
13695
|
if (buffer.length >= maxBufferSize) {
|
|
13538
13696
|
buffer.shift();
|
|
13539
|
-
|
|
13697
|
+
log11.warn("Audit sink buffer full, dropping oldest event");
|
|
13540
13698
|
}
|
|
13541
13699
|
buffer.push(event);
|
|
13542
13700
|
if (buffer.length >= batchSize)
|
|
@@ -14042,6 +14200,68 @@ function createDatadogSink(config) {
|
|
|
14042
14200
|
}
|
|
14043
14201
|
};
|
|
14044
14202
|
}
|
|
14203
|
+
// ../observe/src/audit-sink-jsonl.ts
|
|
14204
|
+
import { mkdir as mkdir2, open } from "node:fs/promises";
|
|
14205
|
+
import { dirname } from "node:path";
|
|
14206
|
+
var log12 = createLogger();
|
|
14207
|
+
function createJsonlSink(config) {
|
|
14208
|
+
const { path, fsync = true } = config;
|
|
14209
|
+
let handle = null;
|
|
14210
|
+
let initPromise = null;
|
|
14211
|
+
let writeChain = Promise.resolve();
|
|
14212
|
+
async function getHandle() {
|
|
14213
|
+
if (handle)
|
|
14214
|
+
return handle;
|
|
14215
|
+
if (initPromise)
|
|
14216
|
+
return initPromise;
|
|
14217
|
+
initPromise = (async () => {
|
|
14218
|
+
await mkdir2(dirname(path), { recursive: true });
|
|
14219
|
+
handle = await open(path, "a");
|
|
14220
|
+
return handle;
|
|
14221
|
+
})();
|
|
14222
|
+
return initPromise;
|
|
14223
|
+
}
|
|
14224
|
+
function withWriteLock(fn) {
|
|
14225
|
+
const previous = writeChain;
|
|
14226
|
+
const next = previous.catch(() => {}).then(fn);
|
|
14227
|
+
writeChain = next;
|
|
14228
|
+
return next;
|
|
14229
|
+
}
|
|
14230
|
+
return {
|
|
14231
|
+
name: "jsonl",
|
|
14232
|
+
async send(events) {
|
|
14233
|
+
if (events.length === 0)
|
|
14234
|
+
return;
|
|
14235
|
+
return withWriteLock(async () => {
|
|
14236
|
+
const fh = await getHandle();
|
|
14237
|
+
const payload = `${events.map((e) => JSON.stringify(e)).join(`
|
|
14238
|
+
`)}
|
|
14239
|
+
`;
|
|
14240
|
+
await fh.appendFile(payload, "utf8");
|
|
14241
|
+
if (fsync) {
|
|
14242
|
+
try {
|
|
14243
|
+
await fh.sync();
|
|
14244
|
+
} catch (err2) {
|
|
14245
|
+
log12.warn("jsonl sink fsync failed", { error: err2 });
|
|
14246
|
+
}
|
|
14247
|
+
}
|
|
14248
|
+
});
|
|
14249
|
+
},
|
|
14250
|
+
async shutdown() {
|
|
14251
|
+
await withWriteLock(async () => {
|
|
14252
|
+
if (handle) {
|
|
14253
|
+
try {
|
|
14254
|
+
if (fsync)
|
|
14255
|
+
await handle.sync();
|
|
14256
|
+
} finally {
|
|
14257
|
+
await handle.close();
|
|
14258
|
+
handle = null;
|
|
14259
|
+
}
|
|
14260
|
+
}
|
|
14261
|
+
});
|
|
14262
|
+
}
|
|
14263
|
+
};
|
|
14264
|
+
}
|
|
14045
14265
|
// ../observe/src/provenance.ts
|
|
14046
14266
|
import { createHash as createHash6 } from "node:crypto";
|
|
14047
14267
|
function sha256(input) {
|
|
@@ -14102,8 +14322,8 @@ function createProvenanceTracker(options) {
|
|
|
14102
14322
|
// ../observe/src/experiment.ts
|
|
14103
14323
|
import { createHash as createHash7 } from "node:crypto";
|
|
14104
14324
|
import { existsSync, mkdirSync, readFileSync, writeFileSync as writeFileSync2 } from "node:fs";
|
|
14105
|
-
import { join } from "node:path";
|
|
14106
|
-
var
|
|
14325
|
+
import { join as join2 } from "node:path";
|
|
14326
|
+
var log13 = createLogger();
|
|
14107
14327
|
function createFileExperimentStore(dir) {
|
|
14108
14328
|
return {
|
|
14109
14329
|
save(name, data) {
|
|
@@ -14111,10 +14331,10 @@ function createFileExperimentStore(dir) {
|
|
|
14111
14331
|
if (!existsSync(dir)) {
|
|
14112
14332
|
mkdirSync(dir, { recursive: true });
|
|
14113
14333
|
}
|
|
14114
|
-
const filePath =
|
|
14334
|
+
const filePath = join2(dir, `${name}.json`);
|
|
14115
14335
|
writeFileSync2(filePath, JSON.stringify(data, null, 2));
|
|
14116
14336
|
} catch (err2) {
|
|
14117
|
-
|
|
14337
|
+
log13.error("Failed to save experiment", {
|
|
14118
14338
|
name,
|
|
14119
14339
|
error: err2 instanceof Error ? err2.message : String(err2)
|
|
14120
14340
|
});
|
|
@@ -14122,7 +14342,7 @@ function createFileExperimentStore(dir) {
|
|
|
14122
14342
|
},
|
|
14123
14343
|
load(name) {
|
|
14124
14344
|
try {
|
|
14125
|
-
const filePath =
|
|
14345
|
+
const filePath = join2(dir, `${name}.json`);
|
|
14126
14346
|
if (!existsSync(filePath))
|
|
14127
14347
|
return null;
|
|
14128
14348
|
const raw = readFileSync(filePath, "utf-8");
|
|
@@ -14145,7 +14365,7 @@ function loadFromStore(store, name, stats) {
|
|
|
14145
14365
|
stats[vName].metrics[key] = { sum: m.sum, count: m.count };
|
|
14146
14366
|
}
|
|
14147
14367
|
}
|
|
14148
|
-
|
|
14368
|
+
log13.debug("Loaded experiment state", { name, totalAssignments: saved.totalAssignments });
|
|
14149
14369
|
}
|
|
14150
14370
|
function recordMetrics(s, metrics) {
|
|
14151
14371
|
for (const [key, value] of Object.entries(metrics)) {
|
|
@@ -14213,7 +14433,7 @@ function createExperiment(config) {
|
|
|
14213
14433
|
const s = stats[variant.name];
|
|
14214
14434
|
if (s)
|
|
14215
14435
|
s.assignments++;
|
|
14216
|
-
|
|
14436
|
+
log13.debug("Experiment assignment", {
|
|
14217
14437
|
experiment: name,
|
|
14218
14438
|
variant: variant.name,
|
|
14219
14439
|
userId
|
|
@@ -14283,8 +14503,8 @@ function instrumentAgent(agent, tracer) {
|
|
|
14283
14503
|
}
|
|
14284
14504
|
// ../observe/src/studio-exporter.ts
|
|
14285
14505
|
import { existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync as readFileSync2, writeFileSync as writeFileSync3 } from "node:fs";
|
|
14286
|
-
import { join as
|
|
14287
|
-
var
|
|
14506
|
+
import { join as join3 } from "node:path";
|
|
14507
|
+
var log14 = createLogger();
|
|
14288
14508
|
function ensureDir(dirPath) {
|
|
14289
14509
|
if (!existsSync2(dirPath)) {
|
|
14290
14510
|
mkdirSync2(dirPath, { recursive: true });
|
|
@@ -14294,7 +14514,7 @@ function safeWriteJSON(filePath, data) {
|
|
|
14294
14514
|
try {
|
|
14295
14515
|
writeFileSync3(filePath, JSON.stringify(data, null, 2));
|
|
14296
14516
|
} catch (err2) {
|
|
14297
|
-
|
|
14517
|
+
log14.error("Studio exporter write failed", {
|
|
14298
14518
|
file: filePath,
|
|
14299
14519
|
error: err2 instanceof Error ? err2.message : String(err2)
|
|
14300
14520
|
});
|
|
@@ -14311,9 +14531,9 @@ function safeReadJSON(filePath, fallback) {
|
|
|
14311
14531
|
}
|
|
14312
14532
|
function createStudioExporter(config) {
|
|
14313
14533
|
const baseDir = config?.dir ?? ".elsium";
|
|
14314
|
-
const tracesDir =
|
|
14315
|
-
const xrayFile =
|
|
14316
|
-
const costFile =
|
|
14534
|
+
const tracesDir = join3(baseDir, "traces");
|
|
14535
|
+
const xrayFile = join3(baseDir, "xray-history.json");
|
|
14536
|
+
const costFile = join3(baseDir, "cost-report.json");
|
|
14317
14537
|
ensureDir(tracesDir);
|
|
14318
14538
|
return {
|
|
14319
14539
|
name: "studio",
|
|
@@ -14321,7 +14541,7 @@ function createStudioExporter(config) {
|
|
|
14321
14541
|
for (const span of spans) {
|
|
14322
14542
|
if (!span.traceId)
|
|
14323
14543
|
continue;
|
|
14324
|
-
const filePath =
|
|
14544
|
+
const filePath = join3(tracesDir, `${span.traceId}.json`);
|
|
14325
14545
|
safeWriteJSON(filePath, span);
|
|
14326
14546
|
}
|
|
14327
14547
|
},
|
|
@@ -14679,7 +14899,7 @@ function formatComplianceReport(report) {
|
|
|
14679
14899
|
`);
|
|
14680
14900
|
}
|
|
14681
14901
|
// ../observe/src/otel.ts
|
|
14682
|
-
var
|
|
14902
|
+
var log15 = createLogger();
|
|
14683
14903
|
var SPAN_KIND_MAP = {
|
|
14684
14904
|
llm: 3,
|
|
14685
14905
|
tool: 1,
|
|
@@ -14820,10 +15040,10 @@ function createOTLPExporter(config) {
|
|
|
14820
15040
|
body: JSON.stringify(payload)
|
|
14821
15041
|
});
|
|
14822
15042
|
if (!response.ok) {
|
|
14823
|
-
|
|
15043
|
+
log15.error(`OTLP export failed: ${response.status} ${response.statusText}`);
|
|
14824
15044
|
}
|
|
14825
15045
|
} catch (err2) {
|
|
14826
|
-
|
|
15046
|
+
log15.error("OTLP export error", { error: err2 instanceof Error ? err2.message : String(err2) });
|
|
14827
15047
|
}
|
|
14828
15048
|
}
|
|
14829
15049
|
function startAutoFlush() {
|
|
@@ -15477,7 +15697,7 @@ var serve = (options, listeningListener) => {
|
|
|
15477
15697
|
return server;
|
|
15478
15698
|
};
|
|
15479
15699
|
|
|
15480
|
-
// ../../node_modules/.bun/hono@4.12.
|
|
15700
|
+
// ../../node_modules/.bun/hono@4.12.18/node_modules/hono/dist/compose.js
|
|
15481
15701
|
var compose = (middleware, onError, onNotFound) => {
|
|
15482
15702
|
return (context, next) => {
|
|
15483
15703
|
let index = -1;
|
|
@@ -15521,10 +15741,10 @@ var compose = (middleware, onError, onNotFound) => {
|
|
|
15521
15741
|
};
|
|
15522
15742
|
};
|
|
15523
15743
|
|
|
15524
|
-
// ../../node_modules/.bun/hono@4.12.
|
|
15744
|
+
// ../../node_modules/.bun/hono@4.12.18/node_modules/hono/dist/request/constants.js
|
|
15525
15745
|
var GET_MATCH_RESULT = /* @__PURE__ */ Symbol();
|
|
15526
15746
|
|
|
15527
|
-
// ../../node_modules/.bun/hono@4.12.
|
|
15747
|
+
// ../../node_modules/.bun/hono@4.12.18/node_modules/hono/dist/utils/body.js
|
|
15528
15748
|
var parseBody = async (request, options = /* @__PURE__ */ Object.create(null)) => {
|
|
15529
15749
|
const { all = false, dot = false } = options;
|
|
15530
15750
|
const headers = request instanceof HonoRequest ? request.raw.headers : request.headers;
|
|
@@ -15595,7 +15815,7 @@ var handleParsingNestedValues = (form, key, value) => {
|
|
|
15595
15815
|
});
|
|
15596
15816
|
};
|
|
15597
15817
|
|
|
15598
|
-
// ../../node_modules/.bun/hono@4.12.
|
|
15818
|
+
// ../../node_modules/.bun/hono@4.12.18/node_modules/hono/dist/utils/url.js
|
|
15599
15819
|
var splitPath = (path) => {
|
|
15600
15820
|
const paths = path.split("/");
|
|
15601
15821
|
if (paths[0] === "") {
|
|
@@ -15795,7 +16015,7 @@ var getQueryParams = (url, key) => {
|
|
|
15795
16015
|
};
|
|
15796
16016
|
var decodeURIComponent_ = decodeURIComponent;
|
|
15797
16017
|
|
|
15798
|
-
// ../../node_modules/.bun/hono@4.12.
|
|
16018
|
+
// ../../node_modules/.bun/hono@4.12.18/node_modules/hono/dist/request.js
|
|
15799
16019
|
var tryDecodeURIComponent = (str) => tryDecode(str, decodeURIComponent_);
|
|
15800
16020
|
var HonoRequest = class {
|
|
15801
16021
|
raw;
|
|
@@ -15906,7 +16126,7 @@ var HonoRequest = class {
|
|
|
15906
16126
|
}
|
|
15907
16127
|
};
|
|
15908
16128
|
|
|
15909
|
-
// ../../node_modules/.bun/hono@4.12.
|
|
16129
|
+
// ../../node_modules/.bun/hono@4.12.18/node_modules/hono/dist/utils/html.js
|
|
15910
16130
|
var HtmlEscapedCallbackPhase = {
|
|
15911
16131
|
Stringify: 1,
|
|
15912
16132
|
BeforeStream: 2,
|
|
@@ -15944,7 +16164,7 @@ var resolveCallback = async (str, phase, preserveCallbacks, context, buffer) =>
|
|
|
15944
16164
|
}
|
|
15945
16165
|
};
|
|
15946
16166
|
|
|
15947
|
-
// ../../node_modules/.bun/hono@4.12.
|
|
16167
|
+
// ../../node_modules/.bun/hono@4.12.18/node_modules/hono/dist/context.js
|
|
15948
16168
|
var TEXT_PLAIN = "text/plain; charset=UTF-8";
|
|
15949
16169
|
var setDefaultContentType = (contentType, headers) => {
|
|
15950
16170
|
return {
|
|
@@ -16111,7 +16331,7 @@ var Context = class {
|
|
|
16111
16331
|
};
|
|
16112
16332
|
};
|
|
16113
16333
|
|
|
16114
|
-
// ../../node_modules/.bun/hono@4.12.
|
|
16334
|
+
// ../../node_modules/.bun/hono@4.12.18/node_modules/hono/dist/router.js
|
|
16115
16335
|
var METHOD_NAME_ALL = "ALL";
|
|
16116
16336
|
var METHOD_NAME_ALL_LOWERCASE = "all";
|
|
16117
16337
|
var METHODS = ["get", "post", "put", "delete", "options", "patch"];
|
|
@@ -16119,10 +16339,10 @@ var MESSAGE_MATCHER_IS_ALREADY_BUILT = "Can not add a route since the matcher is
|
|
|
16119
16339
|
var UnsupportedPathError = class extends Error {
|
|
16120
16340
|
};
|
|
16121
16341
|
|
|
16122
|
-
// ../../node_modules/.bun/hono@4.12.
|
|
16342
|
+
// ../../node_modules/.bun/hono@4.12.18/node_modules/hono/dist/utils/constants.js
|
|
16123
16343
|
var COMPOSED_HANDLER = "__COMPOSED_HANDLER";
|
|
16124
16344
|
|
|
16125
|
-
// ../../node_modules/.bun/hono@4.12.
|
|
16345
|
+
// ../../node_modules/.bun/hono@4.12.18/node_modules/hono/dist/hono-base.js
|
|
16126
16346
|
var notFoundHandler = (c) => {
|
|
16127
16347
|
return c.text("404 Not Found", 404);
|
|
16128
16348
|
};
|
|
@@ -16341,7 +16561,7 @@ var Hono = class _Hono {
|
|
|
16341
16561
|
};
|
|
16342
16562
|
};
|
|
16343
16563
|
|
|
16344
|
-
// ../../node_modules/.bun/hono@4.12.
|
|
16564
|
+
// ../../node_modules/.bun/hono@4.12.18/node_modules/hono/dist/router/reg-exp-router/matcher.js
|
|
16345
16565
|
var emptyParam = [];
|
|
16346
16566
|
function match(method, path) {
|
|
16347
16567
|
const matchers = this.buildAllMatchers();
|
|
@@ -16362,7 +16582,7 @@ function match(method, path) {
|
|
|
16362
16582
|
return match2(method, path);
|
|
16363
16583
|
}
|
|
16364
16584
|
|
|
16365
|
-
// ../../node_modules/.bun/hono@4.12.
|
|
16585
|
+
// ../../node_modules/.bun/hono@4.12.18/node_modules/hono/dist/router/reg-exp-router/node.js
|
|
16366
16586
|
var LABEL_REG_EXP_STR = "[^/]+";
|
|
16367
16587
|
var ONLY_WILDCARD_REG_EXP_STR = ".*";
|
|
16368
16588
|
var TAIL_WILDCARD_REG_EXP_STR = "(?:|/.*)";
|
|
@@ -16466,7 +16686,7 @@ var Node = class _Node {
|
|
|
16466
16686
|
}
|
|
16467
16687
|
};
|
|
16468
16688
|
|
|
16469
|
-
// ../../node_modules/.bun/hono@4.12.
|
|
16689
|
+
// ../../node_modules/.bun/hono@4.12.18/node_modules/hono/dist/router/reg-exp-router/trie.js
|
|
16470
16690
|
var Trie = class {
|
|
16471
16691
|
#context = { varIndex: 0 };
|
|
16472
16692
|
#root = new Node;
|
|
@@ -16522,7 +16742,7 @@ var Trie = class {
|
|
|
16522
16742
|
}
|
|
16523
16743
|
};
|
|
16524
16744
|
|
|
16525
|
-
// ../../node_modules/.bun/hono@4.12.
|
|
16745
|
+
// ../../node_modules/.bun/hono@4.12.18/node_modules/hono/dist/router/reg-exp-router/router.js
|
|
16526
16746
|
var nullMatcher = [/^$/, [], /* @__PURE__ */ Object.create(null)];
|
|
16527
16747
|
var wildcardRegExpCache = /* @__PURE__ */ Object.create(null);
|
|
16528
16748
|
function buildWildcardRegExp(path) {
|
|
@@ -16687,7 +16907,7 @@ var RegExpRouter = class {
|
|
|
16687
16907
|
}
|
|
16688
16908
|
};
|
|
16689
16909
|
|
|
16690
|
-
// ../../node_modules/.bun/hono@4.12.
|
|
16910
|
+
// ../../node_modules/.bun/hono@4.12.18/node_modules/hono/dist/router/reg-exp-router/prepared-router.js
|
|
16691
16911
|
var PreparedRegExpRouter = class {
|
|
16692
16912
|
name = "PreparedRegExpRouter";
|
|
16693
16913
|
#matchers;
|
|
@@ -16759,7 +16979,7 @@ var PreparedRegExpRouter = class {
|
|
|
16759
16979
|
match = match;
|
|
16760
16980
|
};
|
|
16761
16981
|
|
|
16762
|
-
// ../../node_modules/.bun/hono@4.12.
|
|
16982
|
+
// ../../node_modules/.bun/hono@4.12.18/node_modules/hono/dist/router/smart-router/router.js
|
|
16763
16983
|
var SmartRouter = class {
|
|
16764
16984
|
name = "SmartRouter";
|
|
16765
16985
|
#routers = [];
|
|
@@ -16814,7 +17034,7 @@ var SmartRouter = class {
|
|
|
16814
17034
|
}
|
|
16815
17035
|
};
|
|
16816
17036
|
|
|
16817
|
-
// ../../node_modules/.bun/hono@4.12.
|
|
17037
|
+
// ../../node_modules/.bun/hono@4.12.18/node_modules/hono/dist/router/trie-router/node.js
|
|
16818
17038
|
var emptyParams = /* @__PURE__ */ Object.create(null);
|
|
16819
17039
|
var hasChildren = (children) => {
|
|
16820
17040
|
for (const _ in children) {
|
|
@@ -16983,7 +17203,7 @@ var Node2 = class _Node2 {
|
|
|
16983
17203
|
}
|
|
16984
17204
|
};
|
|
16985
17205
|
|
|
16986
|
-
// ../../node_modules/.bun/hono@4.12.
|
|
17206
|
+
// ../../node_modules/.bun/hono@4.12.18/node_modules/hono/dist/router/trie-router/router.js
|
|
16987
17207
|
var TrieRouter = class {
|
|
16988
17208
|
name = "TrieRouter";
|
|
16989
17209
|
#node;
|
|
@@ -17005,7 +17225,7 @@ var TrieRouter = class {
|
|
|
17005
17225
|
}
|
|
17006
17226
|
};
|
|
17007
17227
|
|
|
17008
|
-
// ../../node_modules/.bun/hono@4.12.
|
|
17228
|
+
// ../../node_modules/.bun/hono@4.12.18/node_modules/hono/dist/hono.js
|
|
17009
17229
|
var Hono2 = class extends Hono {
|
|
17010
17230
|
constructor(options = {}) {
|
|
17011
17231
|
super(options);
|
|
@@ -17105,12 +17325,12 @@ function requestIdMiddleware() {
|
|
|
17105
17325
|
};
|
|
17106
17326
|
}
|
|
17107
17327
|
function requestLoggerMiddleware(logger) {
|
|
17108
|
-
const
|
|
17328
|
+
const log16 = logger ?? createLogger();
|
|
17109
17329
|
return async (c, next) => {
|
|
17110
17330
|
const start = Date.now();
|
|
17111
17331
|
await next();
|
|
17112
17332
|
const duration = Date.now() - start;
|
|
17113
|
-
|
|
17333
|
+
log16.info(`${c.req.method} ${c.req.path}`, {
|
|
17114
17334
|
method: c.req.method,
|
|
17115
17335
|
path: c.req.path,
|
|
17116
17336
|
status: c.res.status,
|
|
@@ -17120,7 +17340,7 @@ function requestLoggerMiddleware(logger) {
|
|
|
17120
17340
|
};
|
|
17121
17341
|
}
|
|
17122
17342
|
|
|
17123
|
-
// ../../node_modules/.bun/hono@4.12.
|
|
17343
|
+
// ../../node_modules/.bun/hono@4.12.18/node_modules/hono/dist/utils/stream.js
|
|
17124
17344
|
var StreamingApi = class {
|
|
17125
17345
|
writer;
|
|
17126
17346
|
encoder;
|
|
@@ -17186,7 +17406,7 @@ var StreamingApi = class {
|
|
|
17186
17406
|
}
|
|
17187
17407
|
};
|
|
17188
17408
|
|
|
17189
|
-
// ../../node_modules/.bun/hono@4.12.
|
|
17409
|
+
// ../../node_modules/.bun/hono@4.12.18/node_modules/hono/dist/helper/streaming/utils.js
|
|
17190
17410
|
var isOldBunVersion = () => {
|
|
17191
17411
|
const version = typeof Bun !== "undefined" ? Bun.version : undefined;
|
|
17192
17412
|
if (version === undefined) {
|
|
@@ -17197,7 +17417,7 @@ var isOldBunVersion = () => {
|
|
|
17197
17417
|
return result;
|
|
17198
17418
|
};
|
|
17199
17419
|
|
|
17200
|
-
// ../../node_modules/.bun/hono@4.12.
|
|
17420
|
+
// ../../node_modules/.bun/hono@4.12.18/node_modules/hono/dist/helper/streaming/stream.js
|
|
17201
17421
|
var contextStash = /* @__PURE__ */ new WeakMap;
|
|
17202
17422
|
var stream = (c, cb, onError) => {
|
|
17203
17423
|
const { readable, writable } = new TransformStream;
|
|
@@ -17453,13 +17673,13 @@ function createRoutes(deps) {
|
|
|
17453
17673
|
}
|
|
17454
17674
|
|
|
17455
17675
|
// ../app/src/app.ts
|
|
17456
|
-
var
|
|
17676
|
+
var log16 = createLogger();
|
|
17457
17677
|
function createApp(config) {
|
|
17458
17678
|
const app = new Hono2;
|
|
17459
17679
|
app.onError((err2, c) => {
|
|
17460
17680
|
const statusCode = err2 instanceof ElsiumError ? err2.statusCode ?? 500 : 500;
|
|
17461
17681
|
const code = err2 instanceof ElsiumError ? err2.code : "UNKNOWN";
|
|
17462
|
-
|
|
17682
|
+
log16.error("Unhandled error", { error: err2.message, code, path: c.req.path });
|
|
17463
17683
|
return c.json({ error: err2.message, code }, statusCode);
|
|
17464
17684
|
});
|
|
17465
17685
|
app.notFound((c) => {
|
|
@@ -17505,7 +17725,7 @@ function createApp(config) {
|
|
|
17505
17725
|
});
|
|
17506
17726
|
const serverConfig = config.server ?? {};
|
|
17507
17727
|
app.use("*", requestIdMiddleware());
|
|
17508
|
-
app.use("*", requestLoggerMiddleware(
|
|
17728
|
+
app.use("*", requestLoggerMiddleware(log16));
|
|
17509
17729
|
if (serverConfig.cors) {
|
|
17510
17730
|
app.use("*", corsMiddleware(serverConfig.cors));
|
|
17511
17731
|
}
|
|
@@ -17551,11 +17771,11 @@ function createApp(config) {
|
|
|
17551
17771
|
const drainTimeoutMs = typeof serverConfig.gracefulShutdown === "object" ? serverConfig.gracefulShutdown.drainTimeoutMs : undefined;
|
|
17552
17772
|
shutdownManager = createShutdownManager({
|
|
17553
17773
|
drainTimeoutMs,
|
|
17554
|
-
onDrainStart: () =>
|
|
17555
|
-
onDrainComplete: () =>
|
|
17774
|
+
onDrainStart: () => log16.info("Draining connections..."),
|
|
17775
|
+
onDrainComplete: () => log16.info("Drain complete")
|
|
17556
17776
|
});
|
|
17557
17777
|
}
|
|
17558
|
-
|
|
17778
|
+
log16.info("ElsiumAI server started", {
|
|
17559
17779
|
url: `http://${hostname}:${listenPort}`,
|
|
17560
17780
|
routes: ["POST /chat", "POST /complete", "GET /health", "GET /metrics", "GET /agents"]
|
|
17561
17781
|
});
|
|
@@ -17572,9 +17792,9 @@ function createApp(config) {
|
|
|
17572
17792
|
};
|
|
17573
17793
|
}
|
|
17574
17794
|
// ../app/src/rbac.ts
|
|
17575
|
-
var
|
|
17795
|
+
var log17 = createLogger();
|
|
17576
17796
|
// ../app/src/tenant.ts
|
|
17577
|
-
var
|
|
17797
|
+
var log18 = createLogger();
|
|
17578
17798
|
var tenantUsage = new Map;
|
|
17579
17799
|
function tenantMiddleware(config) {
|
|
17580
17800
|
const { extractTenant, onUnknownTenant = "reject", defaultTenant } = config;
|
|
@@ -17583,13 +17803,13 @@ function tenantMiddleware(config) {
|
|
|
17583
17803
|
if (!tenant) {
|
|
17584
17804
|
if (onUnknownTenant === "default" && defaultTenant) {
|
|
17585
17805
|
c.set("tenant", defaultTenant);
|
|
17586
|
-
|
|
17806
|
+
log18.debug("Using default tenant", { tenantId: defaultTenant.tenantId });
|
|
17587
17807
|
} else {
|
|
17588
17808
|
return c.json({ error: "Tenant identification required" }, 401);
|
|
17589
17809
|
}
|
|
17590
17810
|
} else {
|
|
17591
17811
|
c.set("tenant", tenant);
|
|
17592
|
-
|
|
17812
|
+
log18.debug("Tenant identified", { tenantId: tenant.tenantId });
|
|
17593
17813
|
}
|
|
17594
17814
|
await next();
|
|
17595
17815
|
};
|
|
@@ -18023,7 +18243,7 @@ function createStdioMCPClient(config) {
|
|
|
18023
18243
|
};
|
|
18024
18244
|
}
|
|
18025
18245
|
// ../mcp/src/server.ts
|
|
18026
|
-
var
|
|
18246
|
+
var log19 = createLogger();
|
|
18027
18247
|
function createMCPServer(config) {
|
|
18028
18248
|
let running = false;
|
|
18029
18249
|
const toolMap = new Map(config.tools.map((t) => [t.name, t]));
|
|
@@ -18251,7 +18471,7 @@ function createMCPServer(config) {
|
|
|
18251
18471
|
pendingChunks.shift();
|
|
18252
18472
|
buffer += chunk;
|
|
18253
18473
|
if (buffer.length > MAX_BUFFER_SIZE2) {
|
|
18254
|
-
|
|
18474
|
+
log19.error("MCP server: buffer size limit exceeded, resetting");
|
|
18255
18475
|
buffer = "";
|
|
18256
18476
|
continue;
|
|
18257
18477
|
}
|
|
@@ -18495,26 +18715,26 @@ function computeManifestHash(tools) {
|
|
|
18495
18715
|
const content = tools.map((t) => `${t.name}:${t.inputSchemaHash}`).join("|");
|
|
18496
18716
|
return createHash8("sha256").update(content).digest("hex");
|
|
18497
18717
|
}
|
|
18498
|
-
function
|
|
18499
|
-
if (
|
|
18500
|
-
return
|
|
18501
|
-
|
|
18502
|
-
|
|
18718
|
+
function matchesServer(config, s) {
|
|
18719
|
+
if (s.name !== config.name)
|
|
18720
|
+
return false;
|
|
18721
|
+
if (s.transport !== config.transport)
|
|
18722
|
+
return false;
|
|
18723
|
+
if (config.transport === "http" && s.urlPattern) {
|
|
18724
|
+
if (!new RegExp(s.urlPattern).test(config.url))
|
|
18503
18725
|
return false;
|
|
18504
|
-
|
|
18726
|
+
}
|
|
18727
|
+
if (config.transport === "stdio" && s.commandHash) {
|
|
18728
|
+
const cmdHash = createHash8("sha256").update(`${config.command}:${(config.args ?? []).join(":")}`).digest("hex");
|
|
18729
|
+
if (cmdHash !== s.commandHash)
|
|
18505
18730
|
return false;
|
|
18506
|
-
|
|
18507
|
-
|
|
18508
|
-
|
|
18509
|
-
|
|
18510
|
-
|
|
18511
|
-
if (config.transport === "stdio" && s.commandHash) {
|
|
18512
|
-
const cmdHash = createHash8("sha256").update(`${config.command}:${(config.args ?? []).join(":")}`).digest("hex");
|
|
18513
|
-
if (cmdHash !== s.commandHash)
|
|
18514
|
-
return false;
|
|
18515
|
-
}
|
|
18731
|
+
}
|
|
18732
|
+
return true;
|
|
18733
|
+
}
|
|
18734
|
+
function isServerAllowed(config, trust) {
|
|
18735
|
+
if (!trust.allowedServers?.length)
|
|
18516
18736
|
return true;
|
|
18517
|
-
|
|
18737
|
+
return trust.allowedServers.some((s) => matchesServer(config, s));
|
|
18518
18738
|
}
|
|
18519
18739
|
function isToolAllowed(toolName, serverName, trust) {
|
|
18520
18740
|
if (!trust.allowedServers?.length)
|
|
@@ -19402,7 +19622,7 @@ function createPromptRegistry() {
|
|
|
19402
19622
|
}
|
|
19403
19623
|
// ../testing/src/regression.ts
|
|
19404
19624
|
import { mkdirSync as mkdirSync3, readFileSync as readFileSync3, writeFileSync as writeFileSync4 } from "node:fs";
|
|
19405
|
-
import { dirname } from "node:path";
|
|
19625
|
+
import { dirname as dirname2 } from "node:path";
|
|
19406
19626
|
function makeEmptyResult(name) {
|
|
19407
19627
|
return {
|
|
19408
19628
|
name,
|
|
@@ -19485,7 +19705,7 @@ function createRegressionSuite(name) {
|
|
|
19485
19705
|
updatedAt: Date.now()
|
|
19486
19706
|
};
|
|
19487
19707
|
}
|
|
19488
|
-
mkdirSync3(
|
|
19708
|
+
mkdirSync3(dirname2(path), { recursive: true });
|
|
19489
19709
|
writeFileSync4(path, JSON.stringify(baseline, null, 2));
|
|
19490
19710
|
},
|
|
19491
19711
|
addCase(input, output, score) {
|
|
@@ -19557,7 +19777,7 @@ function createReplayPlayer(entriesOrJson) {
|
|
|
19557
19777
|
};
|
|
19558
19778
|
}
|
|
19559
19779
|
// ../testing/src/dataset.ts
|
|
19560
|
-
import { readFile } from "node:fs/promises";
|
|
19780
|
+
import { readFile as readFile2 } from "node:fs/promises";
|
|
19561
19781
|
import { extname } from "node:path";
|
|
19562
19782
|
function mapRecordToCase(record, options) {
|
|
19563
19783
|
const inputField = options?.inputField ?? "input";
|
|
@@ -19579,7 +19799,7 @@ function mapRecordToCase(record, options) {
|
|
|
19579
19799
|
};
|
|
19580
19800
|
}
|
|
19581
19801
|
async function loadDatasetFromJSON(path, options) {
|
|
19582
|
-
const content = await
|
|
19802
|
+
const content = await readFile2(path, "utf-8");
|
|
19583
19803
|
const parsed = JSON.parse(content);
|
|
19584
19804
|
if (Array.isArray(parsed)) {
|
|
19585
19805
|
return {
|
|
@@ -19621,7 +19841,7 @@ function parseCSVLine2(line) {
|
|
|
19621
19841
|
return fields;
|
|
19622
19842
|
}
|
|
19623
19843
|
async function loadDatasetFromCSV(path, options) {
|
|
19624
|
-
const content = await
|
|
19844
|
+
const content = await readFile2(path, "utf-8");
|
|
19625
19845
|
const lines = content.split(`
|
|
19626
19846
|
`).filter((line) => line.trim().length > 0);
|
|
19627
19847
|
if (lines.length < 2) {
|
|
@@ -19640,7 +19860,7 @@ async function loadDatasetFromCSV(path, options) {
|
|
|
19640
19860
|
return { name: "", cases };
|
|
19641
19861
|
}
|
|
19642
19862
|
async function loadDatasetFromJSONL(path, options) {
|
|
19643
|
-
const content = await
|
|
19863
|
+
const content = await readFile2(path, "utf-8");
|
|
19644
19864
|
const lines = content.split(`
|
|
19645
19865
|
`).filter((line) => line.trim().length > 0);
|
|
19646
19866
|
const cases = lines.map((line) => mapRecordToCase(JSON.parse(line), options));
|
|
@@ -19660,10 +19880,10 @@ async function loadDataset(path, options) {
|
|
|
19660
19880
|
}
|
|
19661
19881
|
}
|
|
19662
19882
|
// ../testing/src/eval-compare.ts
|
|
19663
|
-
import { mkdir, readFile as
|
|
19664
|
-
import { join as
|
|
19883
|
+
import { mkdir as mkdir3, readFile as readFile3, writeFile as writeFile2 } from "node:fs/promises";
|
|
19884
|
+
import { join as join4 } from "node:path";
|
|
19665
19885
|
async function saveBaseline(result, dir) {
|
|
19666
|
-
await
|
|
19886
|
+
await mkdir3(dir, { recursive: true });
|
|
19667
19887
|
const baseline = {
|
|
19668
19888
|
name: result.name,
|
|
19669
19889
|
timestamp: Date.now(),
|
|
@@ -19674,14 +19894,14 @@ async function saveBaseline(result, dir) {
|
|
|
19674
19894
|
score: r.score
|
|
19675
19895
|
}))
|
|
19676
19896
|
};
|
|
19677
|
-
const filePath =
|
|
19678
|
-
await
|
|
19897
|
+
const filePath = join4(dir, `${result.name}.baseline.json`);
|
|
19898
|
+
await writeFile2(filePath, JSON.stringify(baseline, null, "\t"), "utf-8");
|
|
19679
19899
|
return filePath;
|
|
19680
19900
|
}
|
|
19681
19901
|
async function loadBaseline(name, dir) {
|
|
19682
|
-
const filePath =
|
|
19902
|
+
const filePath = join4(dir, `${name}.baseline.json`);
|
|
19683
19903
|
try {
|
|
19684
|
-
const content = await
|
|
19904
|
+
const content = await readFile3(filePath, "utf-8");
|
|
19685
19905
|
return JSON.parse(content);
|
|
19686
19906
|
} catch {
|
|
19687
19907
|
return null;
|
|
@@ -21287,7 +21507,10 @@ export {
|
|
|
21287
21507
|
createMCPHttpHandler,
|
|
21288
21508
|
createMCPClient,
|
|
21289
21509
|
createLogger,
|
|
21510
|
+
createJsonlSink,
|
|
21511
|
+
createJsonFileTaskStore,
|
|
21290
21512
|
createInMemoryThreadStore,
|
|
21513
|
+
createInMemoryTaskStore,
|
|
21291
21514
|
createInMemoryStore,
|
|
21292
21515
|
createInMemoryMemoryStore,
|
|
21293
21516
|
createInMemoryCheckpointStore,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "elsium-ai",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "ElsiumAI — A high-performance, TypeScript-first AI framework",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Eric Utrera <ebutrera9103@gmail.com>",
|
|
@@ -25,17 +25,17 @@
|
|
|
25
25
|
"build": "bun build ./src/index.ts --outdir ./dist --target node && bun x tsc -p tsconfig.build.json --emitDeclarationOnly"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@elsium-ai/core": "^0.
|
|
29
|
-
"@elsium-ai/gateway": "^0.
|
|
30
|
-
"@elsium-ai/agents": "^0.
|
|
31
|
-
"@elsium-ai/tools": "^0.
|
|
32
|
-
"@elsium-ai/rag": "^0.
|
|
33
|
-
"@elsium-ai/workflows": "^0.
|
|
34
|
-
"@elsium-ai/observe": "^0.
|
|
35
|
-
"@elsium-ai/app": "^0.
|
|
36
|
-
"@elsium-ai/testing": "^0.
|
|
37
|
-
"@elsium-ai/mcp": "^0.
|
|
38
|
-
"@elsium-ai/client": "^0.
|
|
28
|
+
"@elsium-ai/core": "^0.11.0",
|
|
29
|
+
"@elsium-ai/gateway": "^0.11.0",
|
|
30
|
+
"@elsium-ai/agents": "^0.11.0",
|
|
31
|
+
"@elsium-ai/tools": "^0.11.0",
|
|
32
|
+
"@elsium-ai/rag": "^0.11.0",
|
|
33
|
+
"@elsium-ai/workflows": "^0.11.0",
|
|
34
|
+
"@elsium-ai/observe": "^0.11.0",
|
|
35
|
+
"@elsium-ai/app": "^0.11.0",
|
|
36
|
+
"@elsium-ai/testing": "^0.11.0",
|
|
37
|
+
"@elsium-ai/mcp": "^0.11.0",
|
|
38
|
+
"@elsium-ai/client": "^0.11.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"typescript": "^5.7.0"
|