@namzu/sdk 0.1.5-rc.2 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/dist/bridge/tools/connector/adapter.d.ts +2 -2
- package/dist/bridge/tools/connector/adapter.d.ts.map +1 -1
- package/dist/bridge/tools/connector/adapter.js +3 -1
- package/dist/bridge/tools/connector/adapter.js.map +1 -1
- package/dist/connector/BaseConnector.d.ts +2 -1
- package/dist/connector/BaseConnector.d.ts.map +1 -1
- package/dist/connector/BaseConnector.js.map +1 -1
- package/dist/connector/builtins/http.d.ts +1 -1
- package/dist/connector/builtins/http.d.ts.map +1 -1
- package/dist/connector/builtins/http.js +1 -1
- package/dist/connector/builtins/http.js.map +1 -1
- package/dist/connector/builtins/webhook.d.ts +1 -1
- package/dist/connector/builtins/webhook.d.ts.map +1 -1
- package/dist/connector/builtins/webhook.js +1 -1
- package/dist/connector/builtins/webhook.js.map +1 -1
- package/dist/index.d.ts +5 -32
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -22
- package/dist/index.js.map +1 -1
- package/dist/manager/connector/environment.d.ts +4 -4
- package/dist/manager/connector/environment.d.ts.map +1 -1
- package/dist/manager/connector/environment.js.map +1 -1
- package/dist/manager/connector/lifecycle.d.ts +2 -2
- package/dist/manager/connector/lifecycle.d.ts.map +1 -1
- package/dist/manager/connector/lifecycle.js.map +1 -1
- package/dist/manager/connector/tenant.d.ts +3 -3
- package/dist/manager/connector/tenant.d.ts.map +1 -1
- package/dist/manager/connector/tenant.js.map +1 -1
- package/dist/manager/index.d.ts +1 -0
- package/dist/manager/index.d.ts.map +1 -1
- package/dist/manager/index.js +1 -0
- package/dist/manager/index.js.map +1 -1
- package/dist/manager/run/emergency.d.ts.map +1 -1
- package/dist/manager/run/emergency.js +44 -12
- package/dist/manager/run/emergency.js.map +1 -1
- package/dist/rag/vector-store.d.ts +2 -2
- package/dist/rag/vector-store.d.ts.map +1 -1
- package/dist/rag/vector-store.js.map +1 -1
- package/dist/registry/connector/scoped.d.ts +5 -4
- package/dist/registry/connector/scoped.d.ts.map +1 -1
- package/dist/registry/connector/scoped.js.map +1 -1
- package/dist/registry/index.d.ts +1 -0
- package/dist/registry/index.d.ts.map +1 -1
- package/dist/registry/index.js +1 -0
- package/dist/registry/index.js.map +1 -1
- package/dist/store/index.d.ts +4 -0
- package/dist/store/index.d.ts.map +1 -1
- package/dist/store/index.js +3 -0
- package/dist/store/index.js.map +1 -1
- package/dist/store/task/__tests__/disk-concurrency.test.d.ts +2 -0
- package/dist/store/task/__tests__/disk-concurrency.test.d.ts.map +1 -0
- package/dist/store/task/__tests__/disk-concurrency.test.js +91 -0
- package/dist/store/task/__tests__/disk-concurrency.test.js.map +1 -0
- package/dist/store/task/disk.d.ts +6 -0
- package/dist/store/task/disk.d.ts.map +1 -1
- package/dist/store/task/disk.js +150 -36
- package/dist/store/task/disk.js.map +1 -1
- package/dist/types/connector/core.d.ts +2 -2
- package/dist/types/connector/core.d.ts.map +1 -1
- package/dist/types/connector/definition.d.ts +7 -7
- package/dist/types/connector/definition.d.ts.map +1 -1
- package/dist/types/connector/mcp.d.ts +4 -4
- package/dist/types/connector/mcp.d.ts.map +1 -1
- package/dist/types/connector/scope.d.ts +3 -2
- package/dist/types/connector/scope.d.ts.map +1 -1
- package/dist/types/connector/scope.js.map +1 -1
- package/dist/types/connector/tenant.d.ts +4 -4
- package/dist/types/connector/tenant.d.ts.map +1 -1
- package/dist/types/rag/knowledge-base.d.ts +2 -2
- package/dist/types/rag/knowledge-base.d.ts.map +1 -1
- package/dist/types/rag/scope.d.ts +2 -1
- package/dist/types/rag/scope.d.ts.map +1 -1
- package/dist/types/rag/storage.d.ts +3 -3
- package/dist/types/rag/storage.d.ts.map +1 -1
- package/dist/types/rag/vector.d.ts +3 -3
- package/dist/types/rag/vector.d.ts.map +1 -1
- package/dist/vault/InMemoryCredentialVault.d.ts +3 -3
- package/dist/vault/InMemoryCredentialVault.d.ts.map +1 -1
- package/dist/vault/InMemoryCredentialVault.js.map +1 -1
- package/package.json +1 -1
- package/src/bridge/tools/connector/adapter.ts +5 -3
- package/src/connector/BaseConnector.ts +2 -1
- package/src/connector/builtins/http.ts +1 -1
- package/src/connector/builtins/webhook.ts +1 -1
- package/src/index.ts +46 -40
- package/src/manager/connector/environment.ts +5 -5
- package/src/manager/connector/lifecycle.ts +2 -2
- package/src/manager/connector/tenant.ts +8 -3
- package/src/manager/index.ts +1 -0
- package/src/manager/run/emergency.ts +45 -16
- package/src/rag/vector-store.ts +2 -2
- package/src/registry/connector/scoped.ts +7 -6
- package/src/registry/index.ts +1 -0
- package/src/store/index.ts +5 -0
- package/src/store/task/__tests__/disk-concurrency.test.ts +118 -0
- package/src/store/task/disk.ts +150 -37
- package/src/types/connector/core.ts +2 -2
- package/src/types/connector/definition.ts +7 -7
- package/src/types/connector/mcp.ts +4 -4
- package/src/types/connector/scope.ts +3 -2
- package/src/types/connector/tenant.ts +4 -4
- package/src/types/rag/knowledge-base.ts +2 -2
- package/src/types/rag/scope.ts +3 -1
- package/src/types/rag/storage.ts +3 -3
- package/src/types/rag/vector.ts +3 -3
- package/src/vault/InMemoryCredentialVault.ts +3 -3
- package/dist/manager/agent/index.d.ts +0 -2
- package/dist/manager/agent/index.d.ts.map +0 -1
- package/dist/manager/agent/index.js +0 -2
- package/dist/manager/agent/index.js.map +0 -1
- package/dist/registry/agent/index.d.ts +0 -2
- package/dist/registry/agent/index.d.ts.map +0 -1
- package/dist/registry/agent/index.js +0 -2
- package/dist/registry/agent/index.js.map +0 -1
- package/dist/router/index.d.ts +0 -2
- package/dist/router/index.d.ts.map +0 -1
- package/dist/router/index.js +0 -2
- package/dist/router/index.js.map +0 -1
- package/src/manager/agent/index.ts +0 -1
- package/src/registry/agent/index.ts +0 -1
- package/src/router/index.ts +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ChunkId, DocumentId, KnowledgeBaseId } from '../ids/index.js';
|
|
1
|
+
import type { ChunkId, DocumentId, KnowledgeBaseId, TenantId } from '../ids/index.js';
|
|
2
2
|
import type { Chunk } from './storage.js';
|
|
3
3
|
export interface VectorSearchResult {
|
|
4
4
|
chunk: Chunk;
|
|
@@ -7,7 +7,7 @@ export interface VectorSearchResult {
|
|
|
7
7
|
export interface VectorStoreQuery {
|
|
8
8
|
embedding: number[];
|
|
9
9
|
topK: number;
|
|
10
|
-
tenantId:
|
|
10
|
+
tenantId: TenantId;
|
|
11
11
|
knowledgeBaseId?: KnowledgeBaseId;
|
|
12
12
|
filter?: Record<string, unknown>;
|
|
13
13
|
minScore?: number;
|
|
@@ -17,6 +17,6 @@ export interface VectorStore {
|
|
|
17
17
|
search(query: VectorStoreQuery): Promise<VectorSearchResult[]>;
|
|
18
18
|
delete(chunkIds: ChunkId[]): Promise<void>;
|
|
19
19
|
deleteByDocument(documentId: DocumentId): Promise<void>;
|
|
20
|
-
deleteByKnowledgeBase(knowledgeBaseId: KnowledgeBaseId, tenantId:
|
|
20
|
+
deleteByKnowledgeBase(knowledgeBaseId: KnowledgeBaseId, tenantId: TenantId): Promise<void>;
|
|
21
21
|
}
|
|
22
22
|
//# sourceMappingURL=vector.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vector.d.ts","sourceRoot":"","sources":["../../../src/types/rag/vector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"vector.d.ts","sourceRoot":"","sources":["../../../src/types/rag/vector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AACrF,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AAEzC,MAAM,WAAW,kBAAkB;IAClC,KAAK,EAAE,KAAK,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;CACb;AAED,MAAM,WAAW,gBAAgB;IAChC,SAAS,EAAE,MAAM,EAAE,CAAA;IACnB,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,QAAQ,CAAA;IAClB,eAAe,CAAC,EAAE,eAAe,CAAA;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAChC,QAAQ,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,WAAW;IAC3B,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACtC,MAAM,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAAA;IAC9D,MAAM,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAC1C,gBAAgB,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACvD,qBAAqB,CAAC,eAAe,EAAE,eAAe,EAAE,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CAC1F"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { AuthConfig, CredentialRef, CredentialVault } from '../types/connector/index.js';
|
|
2
|
-
import type { CredentialId, TenantId } from '../types/ids/index.js';
|
|
2
|
+
import type { ConnectorId, CredentialId, TenantId } from '../types/ids/index.js';
|
|
3
3
|
export declare class InMemoryCredentialVault implements CredentialVault {
|
|
4
4
|
private refs;
|
|
5
5
|
private secrets;
|
|
6
6
|
private log;
|
|
7
7
|
constructor();
|
|
8
|
-
store(tenantId: TenantId, connectorId:
|
|
8
|
+
store(tenantId: TenantId, connectorId: ConnectorId, label: string, auth: AuthConfig): Promise<CredentialRef>;
|
|
9
9
|
retrieve(credentialId: CredentialId): Promise<AuthConfig | undefined>;
|
|
10
10
|
revoke(credentialId: CredentialId): Promise<boolean>;
|
|
11
|
-
list(tenantId: TenantId, connectorId?:
|
|
11
|
+
list(tenantId: TenantId, connectorId?: ConnectorId): Promise<CredentialRef[]>;
|
|
12
12
|
}
|
|
13
13
|
//# sourceMappingURL=InMemoryCredentialVault.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InMemoryCredentialVault.d.ts","sourceRoot":"","sources":["../../src/vault/InMemoryCredentialVault.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAC7F,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"InMemoryCredentialVault.d.ts","sourceRoot":"","sources":["../../src/vault/InMemoryCredentialVault.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAC7F,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAIhF,qBAAa,uBAAwB,YAAW,eAAe;IAC9D,OAAO,CAAC,IAAI,CAA8C;IAC1D,OAAO,CAAC,OAAO,CAA2C;IAC1D,OAAO,CAAC,GAAG,CAAQ;;IAMb,KAAK,CACV,QAAQ,EAAE,QAAQ,EAClB,WAAW,EAAE,WAAW,EACxB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,UAAU,GACd,OAAO,CAAC,aAAa,CAAC;IAiBnB,QAAQ,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC;IAIrE,MAAM,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC;IAUpD,IAAI,CAAC,QAAQ,EAAE,QAAQ,EAAE,WAAW,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;CASnF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InMemoryCredentialVault.js","sourceRoot":"","sources":["../../src/vault/InMemoryCredentialVault.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAA;AACrD,OAAO,EAAe,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAE/D,MAAM,OAAO,uBAAuB;IAC3B,IAAI,GAAqC,IAAI,GAAG,EAAE,CAAA;IAClD,OAAO,GAAkC,IAAI,GAAG,EAAE,CAAA;IAClD,GAAG,CAAQ;IAEnB;QACC,IAAI,CAAC,GAAG,GAAG,aAAa,EAAE,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,yBAAyB,EAAE,CAAC,CAAA;IAC3E,CAAC;IAED,KAAK,CAAC,KAAK,CACV,QAAkB,EAClB,
|
|
1
|
+
{"version":3,"file":"InMemoryCredentialVault.js","sourceRoot":"","sources":["../../src/vault/InMemoryCredentialVault.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAA;AACrD,OAAO,EAAe,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAE/D,MAAM,OAAO,uBAAuB;IAC3B,IAAI,GAAqC,IAAI,GAAG,EAAE,CAAA;IAClD,OAAO,GAAkC,IAAI,GAAG,EAAE,CAAA;IAClD,GAAG,CAAQ;IAEnB;QACC,IAAI,CAAC,GAAG,GAAG,aAAa,EAAE,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,yBAAyB,EAAE,CAAC,CAAA;IAC3E,CAAC;IAED,KAAK,CAAC,KAAK,CACV,QAAkB,EAClB,WAAwB,EACxB,KAAa,EACb,IAAgB;QAEhB,MAAM,EAAE,GAAG,oBAAoB,EAAE,CAAA;QACjC,MAAM,GAAG,GAAkB;YAC1B,EAAE;YACF,WAAW;YACX,QAAQ;YACR,KAAK;YACL,QAAQ,EAAE,IAAI,CAAC,IAAI;YACnB,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;SACrB,CAAA;QAED,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,CAAA;QACtB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,CAAA;QAC1B,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,sBAAsB,EAAE,KAAK,KAAK,gBAAgB,QAAQ,EAAE,CAAC,CAAA;QAC3E,OAAO,GAAG,CAAA;IACX,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,YAA0B;QACxC,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;IACtC,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,YAA0B;QACtC,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;QAC3C,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,CAAA;QAC9B,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,CAAA;QACjC,IAAI,OAAO,EAAE,CAAC;YACb,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,uBAAuB,YAAY,EAAE,CAAC,CAAA;QACrD,CAAC;QACD,OAAO,OAAO,CAAA;IACf,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,QAAkB,EAAE,WAAyB;QACvD,MAAM,OAAO,GAAoB,EAAE,CAAA;QACnC,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;YACtC,IAAI,GAAG,CAAC,QAAQ,KAAK,QAAQ;gBAAE,SAAQ;YACvC,IAAI,WAAW,IAAI,GAAG,CAAC,WAAW,KAAK,WAAW;gBAAE,SAAQ;YAC5D,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QAClB,CAAC;QACD,OAAO,OAAO,CAAA;IACf,CAAC;CACD"}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { z } from 'zod'
|
|
2
2
|
import type { ConnectorManager } from '../../../manager/connector/lifecycle.js'
|
|
3
3
|
import type { ConnectorMethod } from '../../../types/connector/index.js'
|
|
4
|
-
import type { ConnectorInstanceId } from '../../../types/ids/index.js'
|
|
4
|
+
import type { ConnectorId, ConnectorInstanceId } from '../../../types/ids/index.js'
|
|
5
5
|
import type { ToolContext, ToolDefinition, ToolResult } from '../../../types/tool/index.js'
|
|
6
6
|
import { parseConnectorInstanceId } from '../../../utils/id.js'
|
|
7
7
|
|
|
8
8
|
export function connectorMethodToTool(
|
|
9
|
-
connectorId:
|
|
9
|
+
connectorId: ConnectorId,
|
|
10
10
|
instanceId: ConnectorInstanceId,
|
|
11
11
|
method: ConnectorMethod,
|
|
12
12
|
manager: ConnectorManager,
|
|
@@ -64,7 +64,9 @@ export function allConnectorTools(manager: ConnectorManager): ToolDefinition[] {
|
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
const ConnectorRouterInputSchema = z.object({
|
|
67
|
-
connectorId: z
|
|
67
|
+
connectorId: z
|
|
68
|
+
.string()
|
|
69
|
+
.describe('The connector definition ID (e.g., "conn_http", "conn_webhook")'),
|
|
68
70
|
instanceId: z.string().describe('The connector instance ID (e.g., "ci_abc123")'),
|
|
69
71
|
method: z.string().describe('The method to execute on the connector'),
|
|
70
72
|
input: z.record(z.unknown()).describe('The input data for the method'),
|
|
@@ -7,10 +7,11 @@ import type {
|
|
|
7
7
|
ConnectorLifecycle,
|
|
8
8
|
ConnectorMethod,
|
|
9
9
|
} from '../types/connector/index.js'
|
|
10
|
+
import type { ConnectorId } from '../types/ids/index.js'
|
|
10
11
|
import { type Logger, getRootLogger } from '../utils/logger.js'
|
|
11
12
|
|
|
12
13
|
export abstract class BaseConnector<TConfig = unknown> implements ConnectorLifecycle<TConfig> {
|
|
13
|
-
abstract readonly id:
|
|
14
|
+
abstract readonly id: ConnectorId
|
|
14
15
|
abstract readonly name: string
|
|
15
16
|
abstract readonly description: string
|
|
16
17
|
abstract readonly connectionType: ConnectionType
|
|
@@ -25,7 +25,7 @@ const HttpRequestInputSchema = z.object({
|
|
|
25
25
|
})
|
|
26
26
|
|
|
27
27
|
export class HttpConnector extends BaseConnector<HttpConnectorConfig> {
|
|
28
|
-
readonly id = '
|
|
28
|
+
readonly id = 'conn_http' as const
|
|
29
29
|
readonly name = 'HTTP Connector'
|
|
30
30
|
readonly description = 'Generic HTTP/REST API connector for making HTTP requests'
|
|
31
31
|
readonly connectionType: ConnectionType = 'http'
|
|
@@ -25,7 +25,7 @@ const WebhookSendInputSchema = z.object({
|
|
|
25
25
|
})
|
|
26
26
|
|
|
27
27
|
export class WebhookConnector extends BaseConnector<WebhookConnectorConfig> {
|
|
28
|
-
readonly id = '
|
|
28
|
+
readonly id = 'conn_webhook' as const
|
|
29
29
|
readonly name = 'Webhook Connector'
|
|
30
30
|
readonly description = 'Send webhook payloads to configured endpoints with optional HMAC signing'
|
|
31
31
|
readonly connectionType: ConnectionType = 'webhook'
|
package/src/index.ts
CHANGED
|
@@ -96,10 +96,16 @@ export type {
|
|
|
96
96
|
PromptCacheInput,
|
|
97
97
|
} from './runtime/query/context-cache.js'
|
|
98
98
|
export { CheckpointManager } from './runtime/query/checkpoint.js'
|
|
99
|
-
export { DecisionParser } from './runtime/decision/
|
|
100
|
-
|
|
101
|
-
export {
|
|
102
|
-
|
|
99
|
+
export { DecisionParser, FallbackResolver } from './runtime/decision/index.js'
|
|
100
|
+
|
|
101
|
+
export {
|
|
102
|
+
createRunReporter,
|
|
103
|
+
type RunReporter,
|
|
104
|
+
checkLimitsDetailed,
|
|
105
|
+
buildLimitConfig,
|
|
106
|
+
type LimitCheckerState,
|
|
107
|
+
type LimitCheckResult,
|
|
108
|
+
} from './run/index.js'
|
|
103
109
|
|
|
104
110
|
export {
|
|
105
111
|
AbstractAgent,
|
|
@@ -113,18 +119,34 @@ export {
|
|
|
113
119
|
} from './agents/index.js'
|
|
114
120
|
export type { DefineAgentOptions, ConcurrencyMode, Disposable } from './agents/index.js'
|
|
115
121
|
|
|
116
|
-
export {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
+
export {
|
|
123
|
+
InMemoryStore,
|
|
124
|
+
type Identifiable,
|
|
125
|
+
type Timestamped,
|
|
126
|
+
RunDiskStore,
|
|
127
|
+
ActivityStore,
|
|
128
|
+
type ActivityEvent,
|
|
129
|
+
type ActivityEventListener,
|
|
130
|
+
InMemoryTaskStore,
|
|
131
|
+
DiskTaskStore,
|
|
132
|
+
type DiskTaskStoreConfig,
|
|
133
|
+
InMemoryConversationStore,
|
|
134
|
+
type InMemoryConversationStoreConfig,
|
|
135
|
+
InMemoryMemoryIndex,
|
|
136
|
+
InMemoryMemoryStore,
|
|
137
|
+
DiskMemoryStore,
|
|
138
|
+
type DiskMemoryStoreConfig,
|
|
139
|
+
} from './store/index.js'
|
|
122
140
|
|
|
123
|
-
export {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
141
|
+
export {
|
|
142
|
+
Registry,
|
|
143
|
+
ManagedRegistry,
|
|
144
|
+
type ManagedRegistryConfig,
|
|
145
|
+
AgentRegistry,
|
|
146
|
+
PluginRegistry,
|
|
147
|
+
ToolRegistry,
|
|
148
|
+
type ToolExecutionResult,
|
|
149
|
+
} from './registry/index.js'
|
|
128
150
|
|
|
129
151
|
export {
|
|
130
152
|
PluginLifecycleManager,
|
|
@@ -135,18 +157,16 @@ export {
|
|
|
135
157
|
} from './plugin/index.js'
|
|
136
158
|
export type { PluginLifecycleManagerConfig } from './plugin/lifecycle.js'
|
|
137
159
|
|
|
138
|
-
export {
|
|
139
|
-
|
|
140
|
-
|
|
160
|
+
export {
|
|
161
|
+
RunPersistence,
|
|
162
|
+
EmergencySaveManager,
|
|
163
|
+
PlanManager,
|
|
164
|
+
type PlanEvent,
|
|
165
|
+
type PlanEventListener,
|
|
166
|
+
type PlanApprovalHandler,
|
|
167
|
+
AgentManager,
|
|
168
|
+
} from './manager/index.js'
|
|
141
169
|
|
|
142
|
-
export { ActivityStore } from './store/activity/memory.js'
|
|
143
|
-
export type {
|
|
144
|
-
ActivityEvent,
|
|
145
|
-
ActivityEventListener,
|
|
146
|
-
} from './store/activity/memory.js'
|
|
147
|
-
export { InMemoryTaskStore } from './store/task/memory.js'
|
|
148
|
-
export { DiskTaskStore } from './store/task/disk.js'
|
|
149
|
-
export type { DiskTaskStoreConfig } from './store/task/disk.js'
|
|
150
170
|
export {
|
|
151
171
|
buildTaskTools,
|
|
152
172
|
buildTaskCreateTool,
|
|
@@ -156,15 +176,6 @@ export {
|
|
|
156
176
|
export { buildAdvisoryTools } from './tools/advisory/index.js'
|
|
157
177
|
export type { AdvisoryToolsOptions } from './tools/advisory/index.js'
|
|
158
178
|
export { buildMemoryTools } from './tools/memory/index.js'
|
|
159
|
-
export { InMemoryConversationStore } from './store/conversation/memory.js'
|
|
160
|
-
export type { InMemoryConversationStoreConfig } from './store/conversation/memory.js'
|
|
161
|
-
export { PlanManager } from './manager/plan/lifecycle.js'
|
|
162
|
-
export type {
|
|
163
|
-
PlanEvent,
|
|
164
|
-
PlanEventListener,
|
|
165
|
-
PlanApprovalHandler,
|
|
166
|
-
} from './manager/plan/lifecycle.js'
|
|
167
|
-
export { AgentManager } from './manager/agent/lifecycle.js'
|
|
168
179
|
export { LocalTaskGateway } from './gateway/local.js'
|
|
169
180
|
|
|
170
181
|
export {
|
|
@@ -182,8 +193,6 @@ export {
|
|
|
182
193
|
|
|
183
194
|
export { defineTool } from './tools/defineTool.js'
|
|
184
195
|
export type { DefineToolOptions } from './tools/defineTool.js'
|
|
185
|
-
export { ToolRegistry } from './registry/tool/execute.js'
|
|
186
|
-
export type { ToolExecutionResult } from './registry/tool/execute.js'
|
|
187
196
|
export { getBuiltinTools } from './tools/builtins/index.js'
|
|
188
197
|
export { ReadFileTool } from './tools/builtins/read-file.js'
|
|
189
198
|
export { WriteFileTool } from './tools/builtins/write-file.js'
|
|
@@ -304,9 +313,6 @@ export type { ToolCallContext } from './verification/index.js'
|
|
|
304
313
|
export { buildCoordinatorTools } from './tools/coordinator/index.js'
|
|
305
314
|
export type { CoordinatorToolsOptions, TaskLaunchedCallback } from './tools/coordinator/index.js'
|
|
306
315
|
|
|
307
|
-
export { checkLimitsDetailed, buildLimitConfig } from './run/LimitChecker.js'
|
|
308
|
-
export type { LimitCheckerState, LimitCheckResult } from './run/LimitChecker.js'
|
|
309
|
-
|
|
310
316
|
export { InMemoryCredentialVault } from './vault/index.js'
|
|
311
317
|
|
|
312
318
|
export {
|
|
@@ -16,7 +16,7 @@ import type {
|
|
|
16
16
|
ResolvedConnectorConfig,
|
|
17
17
|
ScopeChain,
|
|
18
18
|
} from '../../types/connector/index.js'
|
|
19
|
-
import type { EnvironmentId } from '../../types/ids/index.js'
|
|
19
|
+
import type { ConnectorId, EnvironmentId } from '../../types/ids/index.js'
|
|
20
20
|
import { toErrorMessage } from '../../utils/error.js'
|
|
21
21
|
import { type Logger, getRootLogger } from '../../utils/logger.js'
|
|
22
22
|
import { ConnectorManager } from './lifecycle.js'
|
|
@@ -28,7 +28,7 @@ export interface EnvironmentConnectorSetup {
|
|
|
28
28
|
|
|
29
29
|
executionContext?: ExecutionContextConfig
|
|
30
30
|
|
|
31
|
-
connectorOverrides?: Record<
|
|
31
|
+
connectorOverrides?: Record<ConnectorId, Partial<ConnectorConfig>>
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
export interface EnvironmentConnectorManagerConfig {
|
|
@@ -44,7 +44,7 @@ interface EnvironmentState {
|
|
|
44
44
|
scopeChain: ScopeChain
|
|
45
45
|
manager: ConnectorManager
|
|
46
46
|
executionContext?: BaseExecutionContext
|
|
47
|
-
connectorOverrides: Record<
|
|
47
|
+
connectorOverrides: Record<ConnectorId, Partial<ConnectorConfig>>
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
export class EnvironmentConnectorManager {
|
|
@@ -121,7 +121,7 @@ export class EnvironmentConnectorManager {
|
|
|
121
121
|
|
|
122
122
|
resolveConnectorConfig(
|
|
123
123
|
envId: EnvironmentId,
|
|
124
|
-
connectorId:
|
|
124
|
+
connectorId: ConnectorId,
|
|
125
125
|
): ResolvedConnectorConfig | undefined {
|
|
126
126
|
const state = this.getEnvironmentOrThrow(envId)
|
|
127
127
|
const resolved = this.scopedRegistry.resolve(connectorId, state.scopeChain)
|
|
@@ -147,7 +147,7 @@ export class EnvironmentConnectorManager {
|
|
|
147
147
|
|
|
148
148
|
async createConnectorFromScope(
|
|
149
149
|
envId: EnvironmentId,
|
|
150
|
-
connectorId:
|
|
150
|
+
connectorId: ConnectorId,
|
|
151
151
|
connector: BaseConnector<unknown>,
|
|
152
152
|
): Promise<ConnectorInstance> {
|
|
153
153
|
const state = this.getEnvironmentOrThrow(envId)
|
|
@@ -9,7 +9,7 @@ import type {
|
|
|
9
9
|
ConnectorLifecycleEvent,
|
|
10
10
|
ConnectorStatus,
|
|
11
11
|
} from '../../types/connector/index.js'
|
|
12
|
-
import type { ConnectorInstanceId } from '../../types/ids/index.js'
|
|
12
|
+
import type { ConnectorId, ConnectorInstanceId } from '../../types/ids/index.js'
|
|
13
13
|
import { toErrorMessage } from '../../utils/error.js'
|
|
14
14
|
import { generateConnectorInstanceId } from '../../utils/id.js'
|
|
15
15
|
import { type Logger, getRootLogger } from '../../utils/logger.js'
|
|
@@ -198,7 +198,7 @@ export class ConnectorManager {
|
|
|
198
198
|
return Array.from(this.instances.values())
|
|
199
199
|
}
|
|
200
200
|
|
|
201
|
-
listInstancesByConnector(connectorId:
|
|
201
|
+
listInstancesByConnector(connectorId: ConnectorId): ConnectorInstance[] {
|
|
202
202
|
return this.listInstances().filter((i) => i.connectorId === connectorId)
|
|
203
203
|
}
|
|
204
204
|
|
|
@@ -11,7 +11,12 @@ import type {
|
|
|
11
11
|
TenantDescriptor,
|
|
12
12
|
TenantRateLimitConfig,
|
|
13
13
|
} from '../../types/connector/index.js'
|
|
14
|
-
import type {
|
|
14
|
+
import type {
|
|
15
|
+
ConnectorId,
|
|
16
|
+
ConnectorInstanceId,
|
|
17
|
+
CredentialId,
|
|
18
|
+
TenantId,
|
|
19
|
+
} from '../../types/ids/index.js'
|
|
15
20
|
import { toErrorMessage } from '../../utils/error.js'
|
|
16
21
|
import { type Logger, getRootLogger } from '../../utils/logger.js'
|
|
17
22
|
import { ConnectorManager } from './lifecycle.js'
|
|
@@ -176,7 +181,7 @@ export class TenantConnectorManager {
|
|
|
176
181
|
|
|
177
182
|
async storeCredential(
|
|
178
183
|
tenantId: TenantId,
|
|
179
|
-
connectorId:
|
|
184
|
+
connectorId: ConnectorId,
|
|
180
185
|
label: string,
|
|
181
186
|
auth: import('../../types/connector/index.js').AuthConfig,
|
|
182
187
|
): Promise<import('../../types/connector/index.js').CredentialRef> {
|
|
@@ -189,7 +194,7 @@ export class TenantConnectorManager {
|
|
|
189
194
|
|
|
190
195
|
async listCredentials(
|
|
191
196
|
tenantId: TenantId,
|
|
192
|
-
connectorId?:
|
|
197
|
+
connectorId?: ConnectorId,
|
|
193
198
|
): Promise<import('../../types/connector/index.js').CredentialRef[]> {
|
|
194
199
|
if (!this.credentialVault) {
|
|
195
200
|
return []
|
package/src/manager/index.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto'
|
|
1
2
|
import {
|
|
2
3
|
mkdirSync,
|
|
3
4
|
readFileSync,
|
|
@@ -43,9 +44,15 @@ export class EmergencySaveManager {
|
|
|
43
44
|
this.outputDir = outputDir
|
|
44
45
|
this.log = log.child({ component: 'EmergencySaveManager' })
|
|
45
46
|
|
|
47
|
+
// Attaching a listener for SIGINT/SIGTERM/uncaughtException suppresses
|
|
48
|
+
// Node's default termination behavior. After saving state we MUST
|
|
49
|
+
// terminate explicitly, otherwise Ctrl+C leaves the process running
|
|
50
|
+
// and uncaught errors stop propagating as crashes.
|
|
46
51
|
for (const signal of EMERGENCY_SIGNALS) {
|
|
52
|
+
const exitCode = signal === 'SIGINT' ? 130 : 143 // 128 + signal number
|
|
47
53
|
const handler = (): void => {
|
|
48
54
|
this.emergencySave(signal)
|
|
55
|
+
process.exit(exitCode)
|
|
49
56
|
}
|
|
50
57
|
this.signalHandlers.set(signal, handler)
|
|
51
58
|
process.on(signal, handler)
|
|
@@ -54,6 +61,7 @@ export class EmergencySaveManager {
|
|
|
54
61
|
for (const event of EMERGENCY_EVENTS) {
|
|
55
62
|
const handler = (): void => {
|
|
56
63
|
this.emergencySave(event)
|
|
64
|
+
process.exit(1)
|
|
57
65
|
}
|
|
58
66
|
this.signalHandlers.set(event, handler)
|
|
59
67
|
process.on(event, handler)
|
|
@@ -77,22 +85,43 @@ export class EmergencySaveManager {
|
|
|
77
85
|
return
|
|
78
86
|
}
|
|
79
87
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
88
|
+
let tmpPath: string | undefined
|
|
89
|
+
try {
|
|
90
|
+
const snapshot = runMgr.toEmergencySnapshot(signal)
|
|
91
|
+
|
|
92
|
+
const emergencyDir = join(this.outputDir, '..', EMERGENCY_DIR_NAME)
|
|
93
|
+
mkdirSync(emergencyDir, { recursive: true })
|
|
94
|
+
|
|
95
|
+
tmpPath = join(emergencyDir, `${snapshot.runId}.json.tmp.${randomUUID()}`)
|
|
96
|
+
const finalPath = join(emergencyDir, `${snapshot.runId}.json`)
|
|
97
|
+
|
|
98
|
+
writeFileSync(tmpPath, JSON.stringify(snapshot, null, '\t'), 'utf-8')
|
|
99
|
+
renameSync(tmpPath, finalPath)
|
|
100
|
+
tmpPath = undefined
|
|
101
|
+
|
|
102
|
+
this.log.warn('Emergency save completed', {
|
|
103
|
+
runId: snapshot.runId,
|
|
104
|
+
signal,
|
|
105
|
+
path: finalPath,
|
|
106
|
+
})
|
|
107
|
+
} catch (err) {
|
|
108
|
+
if (tmpPath) {
|
|
109
|
+
try {
|
|
110
|
+
unlinkSync(tmpPath)
|
|
111
|
+
} catch {
|
|
112
|
+
// best-effort cleanup; swallowing here is intentional because we
|
|
113
|
+
// are already in a crash-handling path and must not throw.
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
try {
|
|
117
|
+
this.log.error('Emergency save failed', {
|
|
118
|
+
signal,
|
|
119
|
+
error: err instanceof Error ? err.message : String(err),
|
|
120
|
+
})
|
|
121
|
+
} catch {
|
|
122
|
+
// Logger itself failed — nothing more we can safely do.
|
|
123
|
+
}
|
|
124
|
+
}
|
|
96
125
|
}
|
|
97
126
|
|
|
98
127
|
static listSaves(baseDir: string): string[] {
|
package/src/rag/vector-store.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ChunkId, DocumentId, KnowledgeBaseId } from '../types/ids/index.js'
|
|
1
|
+
import type { ChunkId, DocumentId, KnowledgeBaseId, TenantId } from '../types/ids/index.js'
|
|
2
2
|
import type {
|
|
3
3
|
Chunk,
|
|
4
4
|
VectorSearchResult,
|
|
@@ -57,7 +57,7 @@ export class InMemoryVectorStore implements VectorStore {
|
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
async deleteByKnowledgeBase(knowledgeBaseId: KnowledgeBaseId, tenantId:
|
|
60
|
+
async deleteByKnowledgeBase(knowledgeBaseId: KnowledgeBaseId, tenantId: TenantId): Promise<void> {
|
|
61
61
|
for (const [id, chunk] of this.chunks) {
|
|
62
62
|
if (chunk.knowledgeBaseId === knowledgeBaseId && chunk.tenantId === tenantId) {
|
|
63
63
|
this.chunks.delete(id)
|
|
@@ -8,9 +8,10 @@ import type {
|
|
|
8
8
|
ScopedConnectorConfig,
|
|
9
9
|
} from '../../types/connector/index.js'
|
|
10
10
|
import { CONNECTOR_SCOPE_ORDER } from '../../types/connector/index.js'
|
|
11
|
+
import type { ConnectorId } from '../../types/ids/index.js'
|
|
11
12
|
import { type Logger, getRootLogger } from '../../utils/logger.js'
|
|
12
13
|
|
|
13
|
-
function scopeKey(scope: ConnectorScope, scopeId: string, connectorId:
|
|
14
|
+
function scopeKey(scope: ConnectorScope, scopeId: string, connectorId: ConnectorId): string {
|
|
14
15
|
return `${scope}:${scopeId}:${connectorId}`
|
|
15
16
|
}
|
|
16
17
|
|
|
@@ -28,7 +29,7 @@ export class ScopedConnectorRegistry {
|
|
|
28
29
|
this.log.info(`Scoped config set: ${key}`)
|
|
29
30
|
}
|
|
30
31
|
|
|
31
|
-
remove(scope: ScopeRef, connectorId:
|
|
32
|
+
remove(scope: ScopeRef, connectorId: ConnectorId): boolean {
|
|
32
33
|
const key = scopeKey(scope.scope, scope.scopeId, connectorId)
|
|
33
34
|
const removed = this.configs.delete(key)
|
|
34
35
|
if (removed) {
|
|
@@ -37,11 +38,11 @@ export class ScopedConnectorRegistry {
|
|
|
37
38
|
return removed
|
|
38
39
|
}
|
|
39
40
|
|
|
40
|
-
getAt(scope: ScopeRef, connectorId:
|
|
41
|
+
getAt(scope: ScopeRef, connectorId: ConnectorId): ScopedConnectorConfig | undefined {
|
|
41
42
|
return this.configs.get(scopeKey(scope.scope, scope.scopeId, connectorId))
|
|
42
43
|
}
|
|
43
44
|
|
|
44
|
-
resolve(connectorId:
|
|
45
|
+
resolve(connectorId: ConnectorId, chain: ScopeChain): ResolvedConnectorConfig | undefined {
|
|
45
46
|
const layers: ScopedConnectorConfig[] = []
|
|
46
47
|
|
|
47
48
|
for (const scope of CONNECTOR_SCOPE_ORDER) {
|
|
@@ -59,7 +60,7 @@ export class ScopedConnectorRegistry {
|
|
|
59
60
|
return this.mergeLayers(connectorId, layers)
|
|
60
61
|
}
|
|
61
62
|
|
|
62
|
-
listForConnector(connectorId:
|
|
63
|
+
listForConnector(connectorId: ConnectorId): ScopedConnectorConfig[] {
|
|
63
64
|
const results: ScopedConnectorConfig[] = []
|
|
64
65
|
for (const config of this.configs.values()) {
|
|
65
66
|
if (config.connectorId === connectorId) {
|
|
@@ -81,7 +82,7 @@ export class ScopedConnectorRegistry {
|
|
|
81
82
|
}
|
|
82
83
|
|
|
83
84
|
private mergeLayers(
|
|
84
|
-
connectorId:
|
|
85
|
+
connectorId: ConnectorId,
|
|
85
86
|
layers: ScopedConnectorConfig[],
|
|
86
87
|
): ResolvedConnectorConfig {
|
|
87
88
|
let mergedOptions: Record<string, unknown> = {}
|
package/src/registry/index.ts
CHANGED
package/src/store/index.ts
CHANGED
|
@@ -12,3 +12,8 @@ export type { DiskTaskStoreConfig } from './task/disk.js'
|
|
|
12
12
|
|
|
13
13
|
export { InMemoryConversationStore } from './conversation/memory.js'
|
|
14
14
|
export type { InMemoryConversationStoreConfig } from './conversation/memory.js'
|
|
15
|
+
|
|
16
|
+
export { InMemoryMemoryIndex } from './memory/index.js'
|
|
17
|
+
export { InMemoryMemoryStore } from './memory/memory.js'
|
|
18
|
+
export { DiskMemoryStore } from './memory/disk.js'
|
|
19
|
+
export type { DiskMemoryStoreConfig } from './memory/disk.js'
|