@itphx/synth-backend 0.9.0 → 0.10.1
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/app/bootstrap.d.ts +11 -0
- package/dist/app/bootstrap.js +19 -0
- package/dist/app/deps.d.ts +106 -0
- package/dist/app/deps.js +617 -0
- package/dist/app/listen.d.ts +29 -0
- package/dist/app/listen.js +298 -0
- package/dist/app/mount-routes.d.ts +18 -0
- package/dist/app/mount-routes.js +466 -0
- package/dist/app/sse-events.d.ts +15 -0
- package/dist/app/sse-events.js +83 -0
- package/dist/app.d.ts +29 -3
- package/dist/app.js +110 -900
- package/dist/auth/guards.d.ts +20 -0
- package/dist/auth/guards.js +65 -0
- package/dist/auth/middleware.d.ts +20 -1
- package/dist/auth/middleware.js +53 -1
- package/dist/auth/oidc.d.ts +15 -0
- package/dist/auth/oidc.js +41 -3
- package/dist/auth/service-scope.d.ts +14 -0
- package/dist/auth/service-scope.js +40 -0
- package/dist/events/hub.d.ts +9 -0
- package/dist/events/hub.js +29 -0
- package/dist/lib/cors.d.ts +23 -0
- package/dist/lib/cors.js +24 -0
- package/dist/lib/i18n.js +64 -0
- package/dist/main.js +10 -1
- package/dist/middleware/rate-limiter.d.ts +4 -1
- package/dist/middleware/rate-limiter.js +4 -2
- package/dist/routes/audit.d.ts +1 -1
- package/dist/routes/audit.js +2 -2
- package/dist/routes/auth.js +35 -5
- package/dist/routes/gateway-patterns.d.ts +1 -1
- package/dist/routes/gateway-patterns.js +1 -1
- package/dist/routes/llm.js +7 -4
- package/dist/routes/mcp-registry.d.ts +3 -3
- package/dist/routes/mcp-registry.js +40 -17
- package/dist/routes/mcp.d.ts +1 -1
- package/dist/routes/mcp.js +1 -1
- package/dist/routes/projects.d.ts +7 -4
- package/dist/routes/projects.js +17 -7
- package/dist/routes/providers.js +1 -0
- package/dist/routes/sessions.d.ts +7 -1
- package/dist/routes/sessions.js +119 -8
- package/dist/routes/users.js +17 -4
- package/package.json +4 -4
- package/dist/agents/definitions/admin.json +0 -24
- package/dist/agents/definitions/analyst.json +0 -20
- package/dist/agents/definitions/assistant.json +0 -25
- package/dist/agents/definitions/auditor.json +0 -19
- package/dist/agents/definitions/developer.json +0 -23
- package/dist/agents/definitions/devops.json +0 -23
- package/dist/agents/definitions/explore.json +0 -15
- package/dist/agents/definitions/general.json +0 -15
- package/dist/agents/definitions/pm.json +0 -20
- package/dist/agents/definitions/qa.json +0 -22
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { AuthConfig } from '@itphx/synth-shared';
|
|
2
|
+
import type { FileProfileStore } from '@itphx/synth-core';
|
|
3
|
+
/**
|
|
4
|
+
* Сидировать профили тестовых пользователей (debug mode). Fire-and-forget
|
|
5
|
+
* (паритет с прежним `app.ts`): старт не блокируется, ошибки пишутся в лог.
|
|
6
|
+
*
|
|
7
|
+
* Вызывается в `createBackendDeps` сразу после сборки хранилищ и **до**
|
|
8
|
+
* построения рантайма (оркестратор/события/шедулер) — как в прежнем `app.ts`,
|
|
9
|
+
* где сид стоял между хранилищами и рантаймом.
|
|
10
|
+
*/
|
|
11
|
+
export declare function seedDebugTestUsers(profilesStore: FileProfileStore, auth: AuthConfig): void;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Сидировать профили тестовых пользователей (debug mode). Fire-and-forget
|
|
3
|
+
* (паритет с прежним `app.ts`): старт не блокируется, ошибки пишутся в лог.
|
|
4
|
+
*
|
|
5
|
+
* Вызывается в `createBackendDeps` сразу после сборки хранилищ и **до**
|
|
6
|
+
* построения рантайма (оркестратор/события/шедулер) — как в прежнем `app.ts`,
|
|
7
|
+
* где сид стоял между хранилищами и рантаймом.
|
|
8
|
+
*/
|
|
9
|
+
export function seedDebugTestUsers(profilesStore, auth) {
|
|
10
|
+
// Сидирование тестовых пользователей (debug mode)
|
|
11
|
+
if (auth.debugMode && auth.testUsers) {
|
|
12
|
+
for (const tu of auth.testUsers) {
|
|
13
|
+
profilesStore.getOrCreateProfile({
|
|
14
|
+
username: tu.username,
|
|
15
|
+
roles: tu.roles,
|
|
16
|
+
}).catch((e) => console.warn('seed: failed to create profile for', tu.username, e));
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import type { ProviderConfig, ModelConfig, AgentDefinition, McpNetworkPolicy, DecisionConfig } from '@itphx/synth-shared';
|
|
2
|
+
import { SessionManager, EventBus, QueueProcessorManager, ContextConfig, ContextOptimizer, ChatOrchestrator, FileProfileStore, McpManager, McpRegistryStore, RuntimeSettingsStore, AuditLogger, ProtectedPathsStore, SecretPatternStore, SkillService, CommandService, SkillBundleStore, SSHKeyStore, EventBindingStore, EventApiKeyStore, EventJournalStore, EventRouter, RequestSessionService, EventIngress, RouteRuleStore, IdentityClaimStore, ScheduleStore, SchedulerService, JobStore, WebhookStore, WebhookDeliveryStore, WebhookService, JsonStore, ProjectStore } from '@itphx/synth-core';
|
|
3
|
+
import type { EventsRuntimeSettings } from '@itphx/synth-core';
|
|
4
|
+
import type { BackendConfig } from '../lib/app-config.js';
|
|
5
|
+
import { DefaultsStore } from '../lib/defaults-store.js';
|
|
6
|
+
import { EventHub } from '../events/hub.js';
|
|
7
|
+
/**
|
|
8
|
+
* Собрать зависимости backend-приложения (хранилища/менеджеры/оркестратор/
|
|
9
|
+
* событийное ядро/планировщик/webhooks). Роуты монтирует вызывающий
|
|
10
|
+
* (`mountBackendRoutes`), поэтому здесь нет ни одного `app.*`-вызова.
|
|
11
|
+
*/
|
|
12
|
+
export declare function createBackendDeps(config: BackendConfig): Promise<{
|
|
13
|
+
dataDir: string;
|
|
14
|
+
projectStore: ProjectStore;
|
|
15
|
+
sessionManager: SessionManager;
|
|
16
|
+
stopEphemeralSweeper: () => void;
|
|
17
|
+
sshKeyStore: SSHKeyStore;
|
|
18
|
+
providerStore: JsonStore<ProviderConfig>;
|
|
19
|
+
modelStore: JsonStore<ModelConfig>;
|
|
20
|
+
agentStore: JsonStore<AgentDefinition>;
|
|
21
|
+
contextConfig: ContextConfig;
|
|
22
|
+
profilesStore: FileProfileStore;
|
|
23
|
+
patternStore: SecretPatternStore;
|
|
24
|
+
settingsStore: RuntimeSettingsStore;
|
|
25
|
+
defaultsStore: DefaultsStore;
|
|
26
|
+
defaultWorkingDir: string;
|
|
27
|
+
getDefaultAgentId: () => Promise<string>;
|
|
28
|
+
mcpManager: McpManager;
|
|
29
|
+
mcpRegistryStore: McpRegistryStore;
|
|
30
|
+
eventBus: EventBus;
|
|
31
|
+
queueManager: QueueProcessorManager;
|
|
32
|
+
webhookStore: WebhookStore;
|
|
33
|
+
webhookDeliveryStore: WebhookDeliveryStore;
|
|
34
|
+
webhookService: WebhookService;
|
|
35
|
+
stopWebhookDeliveryPruner: () => void;
|
|
36
|
+
webhooksConfig: {
|
|
37
|
+
enabled: boolean;
|
|
38
|
+
maxAttempts: number;
|
|
39
|
+
timeoutMs: number;
|
|
40
|
+
allowPrivateTargets: boolean;
|
|
41
|
+
deliveryRetentionDays: number;
|
|
42
|
+
};
|
|
43
|
+
providerLoader: (name: string) => ProviderConfig | null;
|
|
44
|
+
providerCache: Map<string, ProviderConfig>;
|
|
45
|
+
modelCache: Map<string, ModelConfig>;
|
|
46
|
+
modelLoader: (model: string) => ModelConfig | null;
|
|
47
|
+
modelWindowLoader: (modelName: string) => number;
|
|
48
|
+
contextOptimizer: ContextOptimizer;
|
|
49
|
+
gatewayAuditLogger: AuditLogger;
|
|
50
|
+
gatewayPayloadLogPath: string;
|
|
51
|
+
gatewayConfig: {
|
|
52
|
+
enabled: boolean;
|
|
53
|
+
inputMode: "block" | "obfuscate";
|
|
54
|
+
logPayloads: boolean;
|
|
55
|
+
payloadLogPath: string;
|
|
56
|
+
rateLimit: {
|
|
57
|
+
userPerMinute: number;
|
|
58
|
+
providerPerMinute: number;
|
|
59
|
+
};
|
|
60
|
+
audit: {
|
|
61
|
+
enabled: boolean;
|
|
62
|
+
logPath: string;
|
|
63
|
+
};
|
|
64
|
+
} | undefined;
|
|
65
|
+
protectedPathsStore: ProtectedPathsStore;
|
|
66
|
+
toolRegistry: import("@itphx/synth-core").ToolRegistry;
|
|
67
|
+
agentRegistry: import("@itphx/synth-core").AgentRegistry;
|
|
68
|
+
skillService: SkillService;
|
|
69
|
+
bundleStore: SkillBundleStore;
|
|
70
|
+
commandService: CommandService;
|
|
71
|
+
orchestrator: ChatOrchestrator;
|
|
72
|
+
processMessage: (session: import("@itphx/synth-shared").Session, message: import("@itphx/synth-shared").Message, signal: AbortSignal, publishChunk: (event: string, data: Record<string, unknown>) => void, attempt?: number) => Promise<import("@itphx/synth-core").ProcessMessageResult>;
|
|
73
|
+
eventBindingStore: EventBindingStore;
|
|
74
|
+
eventApiKeyStore: EventApiKeyStore;
|
|
75
|
+
eventJournal: EventJournalStore;
|
|
76
|
+
routeRuleStore: RouteRuleStore;
|
|
77
|
+
identityClaimStore: IdentityClaimStore;
|
|
78
|
+
eventRouter: EventRouter;
|
|
79
|
+
stopEventJournalPruner: () => void;
|
|
80
|
+
scheduleStore: ScheduleStore;
|
|
81
|
+
jobStore: JobStore;
|
|
82
|
+
resolveAgentTemplate: (template: string) => string | null;
|
|
83
|
+
eventHub: EventHub;
|
|
84
|
+
requestSessionService: RequestSessionService;
|
|
85
|
+
eventIngress: EventIngress;
|
|
86
|
+
schedulerService: SchedulerService;
|
|
87
|
+
/**
|
|
88
|
+
* Живые (мутируемые) эффективные настройки — аксессоры, а не значения:
|
|
89
|
+
* обновляются админкой в рантайме (`mountBackendRoutes`), читаются
|
|
90
|
+
* потребителями через замыкания (ADR-071 §2.3.1 / ADR-084 / ADR-089).
|
|
91
|
+
*/
|
|
92
|
+
live: {
|
|
93
|
+
/** ADR-071 §2.3.1: эффективная политика сетевого доступа MCP. */
|
|
94
|
+
getNetworkPolicy: () => McpNetworkPolicy | undefined;
|
|
95
|
+
/** ADR-071 §2.3.1: live-применение политики (админка → менеджер MCP). */
|
|
96
|
+
setNetworkPolicy: (policy: McpNetworkPolicy) => void;
|
|
97
|
+
/** ADR-089: runtime-настройки «События» (`enabled`/per-key лимит — роуты). */
|
|
98
|
+
getEvents: () => EventsRuntimeSettings;
|
|
99
|
+
/** ADR-089: live-применение runtime-настроек «События» — Router/funnel/pruner. */
|
|
100
|
+
setEvents: (effective: EventsRuntimeSettings) => void;
|
|
101
|
+
/** ADR-084: live-применение runtime-настроек decision-слоя (микро-каскад/роутер). */
|
|
102
|
+
setDecision: (effective: DecisionConfig) => void;
|
|
103
|
+
};
|
|
104
|
+
}>;
|
|
105
|
+
/** Зависимости backend-приложения (то, что вернул `createBackendDeps`). */
|
|
106
|
+
export type BackendDeps = Awaited<ReturnType<typeof createBackendDeps>>;
|