@capybara-hq/kernel 0.1.0-rc.5 → 0.1.0-rc.7
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/bootstrap.json +27 -3
- package/dist/admin/admin.controller.d.ts +21 -74
- package/dist/admin/admin.controller.js +50 -50
- package/dist/admin/admin.schemas.d.ts +57 -0
- package/dist/admin/admin.schemas.js +50 -0
- package/dist/admin/extensions.controller.d.ts +10 -0
- package/dist/admin/extensions.controller.js +18 -0
- package/dist/admin/extensions.schemas.d.ts +7 -0
- package/dist/admin/extensions.schemas.js +10 -0
- package/dist/admin/limit-defaults.d.ts +20 -0
- package/dist/admin/limit-defaults.js +10 -0
- package/dist/agents/agent-profile.service.d.ts +7 -5
- package/dist/agents/agent-profile.service.js +14 -9
- package/dist/agents/agents.controller.d.ts +7 -287
- package/dist/agents/agents.controller.js +7 -67
- package/dist/agents/agents.schemas.d.ts +389 -0
- package/dist/agents/agents.schemas.js +126 -0
- package/dist/agents/agents.service.d.ts +16 -6
- package/dist/agents/agents.service.js +75 -19
- package/dist/agents/definition.d.ts +47 -19
- package/dist/agents/definition.js +119 -38
- package/dist/agents/from-template.d.ts +2 -2
- package/dist/agents/from-template.js +76 -45
- package/dist/agents/from-template.service.d.ts +12 -0
- package/dist/agents/from-template.service.js +23 -6
- package/dist/agents/models.controller.d.ts +33 -5
- package/dist/agents/models.controller.js +50 -6
- package/dist/agents/org-templates.d.ts +13 -3
- package/dist/agents/org-templates.js +69 -28
- package/dist/agents/pending-connector-requests.d.ts +2 -0
- package/dist/agents/pending-connector-requests.js +1 -1
- package/dist/agents/pending-connectors.controller.d.ts +1 -1
- package/dist/agents/pending-connectors.controller.js +2 -2
- package/dist/agents/pending-connectors.service.d.ts +2 -2
- package/dist/agents/pending-connectors.service.js +19 -19
- package/dist/agents/profile.d.ts +18 -0
- package/dist/agents/profile.js +5 -1
- package/dist/agents/readiness.controller.d.ts +5 -5
- package/dist/agents/readiness.controller.js +6 -6
- package/dist/agents/templates.controller.d.ts +8 -17
- package/dist/agents/templates.controller.js +13 -31
- package/dist/agents/templates.schemas.d.ts +20 -0
- package/dist/agents/templates.schemas.js +45 -0
- package/dist/background/background.controller.js +3 -2
- package/dist/background/background.schemas.d.ts +10 -0
- package/dist/background/background.schemas.js +16 -0
- package/dist/background/tasks.service.d.ts +1 -1
- package/dist/background/tasks.service.js +7 -2
- package/dist/catalog/admin-catalog.controller.d.ts +4 -57
- package/dist/catalog/admin-catalog.controller.js +8 -45
- package/dist/catalog/admin-catalog.schemas.d.ts +72 -0
- package/dist/catalog/admin-catalog.schemas.js +92 -0
- package/dist/catalog/catalog-content.d.ts +12 -2
- package/dist/catalog/catalog-scope.service.js +8 -2
- package/dist/catalog/catalog.service.d.ts +2 -0
- package/dist/catalog/catalog.service.js +3 -0
- package/dist/catalog/component-scope.controller.d.ts +3 -65
- package/dist/catalog/component-scope.controller.js +3 -56
- package/dist/catalog/component-scope.schemas.d.ts +114 -0
- package/dist/catalog/component-scope.schemas.js +97 -0
- package/dist/catalog/component-scope.service.d.ts +28 -4
- package/dist/catalog/component-scope.service.js +55 -3
- package/dist/catalog/component-state.d.ts +9 -2
- package/dist/catalog/component-state.js +22 -13
- package/dist/catalog/marketplaces.controller.d.ts +5 -35
- package/dist/catalog/marketplaces.controller.js +6 -34
- package/dist/catalog/marketplaces.schemas.d.ts +48 -0
- package/dist/catalog/marketplaces.schemas.js +53 -0
- package/dist/catalog/marketplaces.service.d.ts +15 -1
- package/dist/catalog/marketplaces.service.js +22 -1
- package/dist/catalog/org-catalog.controller.d.ts +6 -62
- package/dist/catalog/org-catalog.controller.js +12 -66
- package/dist/catalog/org-catalog.schemas.d.ts +79 -0
- package/dist/catalog/org-catalog.schemas.js +82 -0
- package/dist/catalog/org-catalog.service.d.ts +9 -2
- package/dist/catalog/org-catalog.service.js +38 -5
- package/dist/catalog/org-extension.controller.d.ts +1 -12
- package/dist/catalog/org-extension.controller.js +1 -10
- package/dist/catalog/org-extension.schemas.d.ts +15 -0
- package/dist/catalog/org-extension.schemas.js +22 -0
- package/dist/catalog/org-plugin-uploads.controller.d.ts +2 -19
- package/dist/catalog/org-plugin-uploads.controller.js +15 -28
- package/dist/catalog/org-plugin-uploads.schemas.d.ts +20 -0
- package/dist/catalog/org-plugin-uploads.schemas.js +32 -0
- package/dist/catalog/owned-items.d.ts +6 -2
- package/dist/catalog/owned-items.js +16 -4
- package/dist/catalog/platform-components.d.ts +2 -0
- package/dist/catalog/platform-components.js +2 -0
- package/dist/catalog/plugin-import.js +1 -0
- package/dist/catalog/plugin-install.js +1 -1
- package/dist/catalog/requests.service.d.ts +2 -1
- package/dist/catalog/requests.service.js +6 -2
- package/dist/channels/channels.schemas.d.ts +33 -0
- package/dist/channels/channels.schemas.js +34 -0
- package/dist/channels/connections.controller.d.ts +2 -29
- package/dist/channels/connections.controller.js +1 -23
- package/dist/channels/connections.service.d.ts +8 -2
- package/dist/channels/connections.service.js +23 -5
- package/dist/channels/inbound.js +4 -0
- package/dist/config/schema.d.ts +4 -0
- package/dist/config/schema.js +24 -0
- package/dist/conversations/conversations.controller.d.ts +16 -37
- package/dist/conversations/conversations.controller.js +16 -56
- package/dist/conversations/conversations.schemas.d.ts +52 -0
- package/dist/conversations/conversations.schemas.js +79 -0
- package/dist/conversations/conversations.service.d.ts +13 -4
- package/dist/conversations/conversations.service.js +32 -26
- package/dist/conversations/events.d.ts +80 -6
- package/dist/conversations/events.js +60 -5
- package/dist/conversations/message-context.d.ts +28 -0
- package/dist/conversations/message-context.js +56 -0
- package/dist/conversations/queue.d.ts +2 -1
- package/dist/conversations/queue.js +11 -2
- package/dist/ctx/create-ctx.d.ts +15 -1
- package/dist/ctx/create-ctx.js +23 -2
- package/dist/db/kernel-schema.d.ts +44 -0
- package/dist/environments/environments.schemas.d.ts +3 -0
- package/dist/environments/environments.schemas.js +14 -0
- package/dist/environments/environments.service.d.ts +16 -4
- package/dist/environments/environments.service.js +58 -13
- package/dist/errors.d.ts +6 -0
- package/dist/errors.js +6 -0
- package/dist/evals/evals.schemas.d.ts +110 -0
- package/dist/evals/evals.schemas.js +107 -0
- package/dist/evals/reconstruct.js +18 -11
- package/dist/evals/recorded-tools.d.ts +2 -1
- package/dist/evals/recorded-tools.js +11 -3
- package/dist/evals/run-replay.d.ts +8 -1
- package/dist/evals/run-replay.js +17 -2
- package/dist/evals/runs.controller.d.ts +2 -57
- package/dist/evals/runs.controller.js +1 -42
- package/dist/evals/runs.service.d.ts +8 -7
- package/dist/evals/runs.service.js +45 -30
- package/dist/evals/sets.controller.d.ts +2 -28
- package/dist/evals/sets.controller.js +1 -31
- package/dist/evals/sets.service.d.ts +7 -7
- package/dist/evals/sets.service.js +23 -17
- package/dist/evals/snapshot.d.ts +3 -2
- package/dist/evals/snapshot.js +17 -4
- package/dist/evals/step-replay.d.ts +2 -1
- package/dist/evals/step-replay.js +3 -2
- package/dist/extensions/admin-ops.d.ts +5 -3
- package/dist/extensions/admin-ops.js +17 -12
- package/dist/extensions/config-hash.d.ts +10 -0
- package/dist/extensions/config-hash.js +38 -0
- package/dist/extensions/deployment-config.d.ts +16 -1
- package/dist/extensions/deployment-config.js +83 -0
- package/dist/extensions/extensions.module.js +9 -12
- package/dist/extensions/host.d.ts +39 -12
- package/dist/extensions/host.js +129 -51
- package/dist/extensions/installs.d.ts +5 -0
- package/dist/extensions/installs.js +12 -0
- package/dist/extensions/org-config.d.ts +17 -2
- package/dist/extensions/org-config.js +23 -4
- package/dist/extensions/point-defaults.controller.d.ts +2 -8
- package/dist/extensions/point-defaults.controller.js +1 -3
- package/dist/extensions/point-defaults.d.ts +3 -1
- package/dist/extensions/point-defaults.js +4 -2
- package/dist/extensions/point-defaults.schemas.d.ts +9 -0
- package/dist/extensions/point-defaults.schemas.js +14 -0
- package/dist/extensions/state.module.d.ts +9 -0
- package/dist/extensions/state.module.js +38 -0
- package/dist/extensions/unavailable.d.ts +49 -0
- package/dist/extensions/unavailable.js +113 -0
- package/dist/files/previewers.controller.js +2 -3
- package/dist/files/previewers.d.ts +1 -1
- package/dist/files/previewers.js +4 -4
- package/dist/files/previewers.schemas.d.ts +10 -0
- package/dist/files/previewers.schemas.js +9 -0
- package/dist/http/api.module.js +4 -0
- package/dist/http/plugin-dispatch.d.ts +4 -1
- package/dist/http/plugin-dispatch.js +14 -2
- package/dist/identity/accounts.d.ts +43 -4
- package/dist/identity/accounts.js +74 -6
- package/dist/identity/auth.guard.js +10 -1
- package/dist/identity/cookies.d.ts +6 -0
- package/dist/identity/cookies.js +14 -0
- package/dist/identity/identity.module.js +3 -0
- package/dist/identity/initial-passwords.controller.d.ts +22 -0
- package/dist/identity/initial-passwords.controller.js +49 -0
- package/dist/identity/initial-passwords.d.ts +61 -0
- package/dist/identity/initial-passwords.job.d.ts +16 -0
- package/dist/identity/initial-passwords.job.js +46 -0
- package/dist/identity/initial-passwords.js +159 -0
- package/dist/identity/me.controller.d.ts +14 -0
- package/dist/identity/me.controller.js +39 -1
- package/dist/identity/principal.d.ts +8 -0
- package/dist/identity/principal.js +8 -0
- package/dist/identity/settings.d.ts +3 -1
- package/dist/identity/settings.js +6 -4
- package/dist/inbox/inbox.schemas.d.ts +8 -0
- package/dist/inbox/inbox.schemas.js +11 -0
- package/dist/inbox/platform-inbox.controller.d.ts +1 -1
- package/dist/inbox/platform-inbox.controller.js +2 -2
- package/dist/index.d.ts +4 -0
- package/dist/index.js +6 -0
- package/dist/infra/config/kernel-config.service.js +3 -0
- package/dist/infra/events/kernel-events.d.ts +8 -0
- package/dist/lifecycle/kernel-lifecycle.js +4 -0
- package/dist/models/embeddings.d.ts +82 -0
- package/dist/models/embeddings.js +326 -0
- package/dist/models/enablement.controller.d.ts +40 -0
- package/dist/models/enablement.controller.js +74 -0
- package/dist/models/enablement.d.ts +101 -0
- package/dist/models/enablement.js +264 -0
- package/dist/models/models.module.d.ts +5 -1
- package/dist/models/models.module.js +16 -4
- package/dist/models/org-models.schemas.d.ts +8 -0
- package/dist/models/org-models.schemas.js +22 -0
- package/dist/models/prices.d.ts +3 -1
- package/dist/models/prices.js +7 -5
- package/dist/models/purposes.d.ts +30 -6
- package/dist/models/purposes.js +68 -17
- package/dist/orgs/orgs.controller.d.ts +2 -5
- package/dist/orgs/orgs.controller.js +3 -6
- package/dist/orgs/orgs.schemas.d.ts +8 -0
- package/dist/orgs/orgs.schemas.js +16 -0
- package/dist/orgs/orgs.service.d.ts +3 -1
- package/dist/orgs/orgs.service.js +6 -4
- package/dist/orgs/settings.service.d.ts +9 -1
- package/dist/orgs/settings.service.js +20 -5
- package/dist/overrides.d.ts +4 -0
- package/dist/overrides.js +2 -0
- package/dist/platform/errors.d.ts +21 -4
- package/dist/platform/errors.js +45 -6
- package/dist/platform/exclusions.d.ts +2 -3
- package/dist/platform/exclusions.js +68 -831
- package/dist/platform/method.js +1 -1
- package/dist/platform/operation.d.ts +82 -5
- package/dist/platform/operation.js +62 -7
- package/dist/platform/ops/accounts.ops.d.ts +32 -0
- package/dist/platform/ops/accounts.ops.js +291 -0
- package/dist/platform/ops/admin.ops.d.ts +36 -0
- package/dist/platform/ops/admin.ops.js +389 -0
- package/dist/platform/ops/agent-skills.ops.d.ts +24 -0
- package/dist/platform/ops/agent-skills.ops.js +226 -0
- package/dist/platform/ops/agent-templates.ops.d.ts +4 -1
- package/dist/platform/ops/agent-templates.ops.js +194 -14
- package/dist/platform/ops/agents.ops.d.ts +19 -1
- package/dist/platform/ops/agents.ops.js +481 -58
- package/dist/platform/ops/approvals.ops.d.ts +30 -0
- package/dist/platform/ops/approvals.ops.js +116 -0
- package/dist/platform/ops/background.ops.d.ts +14 -0
- package/dist/platform/ops/background.ops.js +134 -0
- package/dist/platform/ops/catalog-admin.ops.d.ts +74 -0
- package/dist/platform/ops/catalog-admin.ops.js +587 -0
- package/dist/platform/ops/channels.ops.d.ts +16 -0
- package/dist/platform/ops/channels.ops.js +195 -0
- package/dist/platform/ops/components.ops.d.ts +46 -0
- package/dist/platform/ops/components.ops.js +853 -0
- package/dist/platform/ops/connectors.ops.d.ts +4 -2
- package/dist/platform/ops/connectors.ops.js +68 -6
- package/dist/platform/ops/conversations.ops.d.ts +30 -0
- package/dist/platform/ops/conversations.ops.js +470 -0
- package/dist/platform/ops/environments.ops.d.ts +26 -0
- package/dist/platform/ops/environments.ops.js +289 -0
- package/dist/platform/ops/errors.d.ts +10 -5
- package/dist/platform/ops/errors.js +19 -11
- package/dist/platform/ops/evals.ops.d.ts +28 -0
- package/dist/platform/ops/evals.ops.js +783 -0
- package/dist/platform/ops/extensions-admin.ops.d.ts +25 -0
- package/dist/platform/ops/extensions-admin.ops.js +344 -0
- package/dist/platform/ops/extensions.ops.d.ts +7 -1
- package/dist/platform/ops/extensions.ops.js +248 -17
- package/dist/platform/ops/inbox.ops.d.ts +25 -0
- package/dist/platform/ops/inbox.ops.js +378 -0
- package/dist/platform/ops/marketplaces.ops.d.ts +7 -1
- package/dist/platform/ops/marketplaces.ops.js +326 -17
- package/dist/platform/ops/models.ops.d.ts +25 -0
- package/dist/platform/ops/models.ops.js +232 -0
- package/dist/platform/ops/org-plugins.ops.d.ts +29 -0
- package/dist/platform/ops/org-plugins.ops.js +329 -0
- package/dist/platform/ops/org-settings.ops.d.ts +16 -0
- package/dist/platform/ops/org-settings.ops.js +102 -0
- package/dist/platform/ops/orgs.ops.d.ts +28 -0
- package/dist/platform/ops/orgs.ops.js +295 -0
- package/dist/platform/ops/other-orgs.d.ts +20 -0
- package/dist/platform/ops/other-orgs.js +72 -0
- package/dist/platform/ops/platform.ops.d.ts +4 -4
- package/dist/platform/ops/platform.ops.js +23 -24
- package/dist/platform/ops/plugins.ops.d.ts +10 -8
- package/dist/platform/ops/plugins.ops.js +176 -77
- package/dist/platform/ops/previewers.ops.d.ts +14 -0
- package/dist/platform/ops/previewers.ops.js +109 -0
- package/dist/platform/ops/requests.ops.js +57 -19
- package/dist/platform/ops/skills.ops.d.ts +5 -1
- package/dist/platform/ops/skills.ops.js +129 -11
- package/dist/platform/ops/unavailable.d.ts +23 -0
- package/dist/platform/ops/unavailable.js +111 -0
- package/dist/platform/parity.d.ts +33 -0
- package/dist/platform/parity.js +272 -0
- package/dist/platform/platform-ops.module.d.ts +32 -0
- package/dist/platform/platform-ops.module.js +78 -11
- package/dist/platform/route-schemas.d.ts +18 -0
- package/dist/platform/route-schemas.js +60 -0
- package/dist/roles/worker.module.js +2 -0
- package/dist/runtime/context/build.d.ts +2 -0
- package/dist/runtime/context/build.js +28 -2
- package/dist/runtime/context/compaction.js +10 -1
- package/dist/runtime/context/run-context.d.ts +65 -0
- package/dist/runtime/context/run-context.js +215 -0
- package/dist/runtime/hook-calls.d.ts +8 -1
- package/dist/runtime/hook-calls.js +40 -9
- package/dist/runtime/model-call.d.ts +8 -3
- package/dist/runtime/model-call.js +30 -6
- package/dist/runtime/providers.d.ts +146 -32
- package/dist/runtime/providers.js +328 -67
- package/dist/runtime/run-context.service.d.ts +65 -0
- package/dist/runtime/run-context.service.js +220 -0
- package/dist/runtime/run-worker.d.ts +6 -1
- package/dist/runtime/run-worker.js +35 -10
- package/dist/runtime/runtime.module.js +2 -0
- package/dist/runtime/subagents/definition.d.ts +15 -15
- package/dist/runtime/subagents/definition.js +49 -118
- package/dist/runtime/usage-report-jobs.d.ts +88 -0
- package/dist/runtime/usage-report-jobs.js +158 -0
- package/dist/runtime/usage-report.d.ts +33 -38
- package/dist/runtime/usage-report.js +152 -84
- package/dist/skills/changes.controller.js +2 -1
- package/dist/skills/changes.service.d.ts +1 -1
- package/dist/skills/changes.service.js +4 -4
- package/dist/skills/invocable.controller.d.ts +1 -1
- package/dist/skills/invocable.controller.js +2 -2
- package/dist/skills/invoke.d.ts +2 -2
- package/dist/skills/invoke.js +8 -1
- package/dist/skills/skills.controller.d.ts +4 -13
- package/dist/skills/skills.controller.js +8 -24
- package/dist/skills/skills.schemas.d.ts +48 -0
- package/dist/skills/skills.schemas.js +61 -0
- package/dist/skills/skills.service.d.ts +11 -1
- package/dist/skills/skills.service.js +37 -14
- package/dist/time-zone.d.ts +5 -0
- package/dist/time-zone.js +19 -0
- package/dist/tools/approvals.controller.js +2 -3
- package/dist/tools/approvals.schemas.d.ts +21 -0
- package/dist/tools/approvals.schemas.js +15 -0
- package/dist/tools/builtin-names.d.ts +10 -8
- package/dist/tools/builtin-names.js +16 -11
- package/dist/tools/builtins/builtin-tools.d.ts +3 -1
- package/dist/tools/builtins/builtin-tools.js +15 -3
- package/dist/tools/builtins/current-time.d.ts +26 -0
- package/dist/tools/builtins/current-time.js +99 -0
- package/dist/tools/builtins/platform.d.ts +19 -2
- package/dist/tools/builtins/platform.js +105 -16
- package/dist/tools/connectors.controller.d.ts +1 -2
- package/dist/tools/connectors.controller.js +1 -4
- package/dist/tools/connectors.schemas.d.ts +12 -0
- package/dist/tools/connectors.schemas.js +19 -0
- package/dist/tools/connectors.service.d.ts +5 -2
- package/dist/tools/connectors.service.js +7 -5
- package/dist/tools/org-tool-switches.d.ts +16 -2
- package/dist/tools/org-tool-switches.js +26 -9
- package/dist/tools/pipeline.js +9 -1
- package/dist/tools/registry.d.ts +48 -51
- package/dist/tools/registry.js +222 -233
- package/package.json +3 -3
- package/src/migrations/0089_model_kinds_usage.sql +38 -0
- package/src/migrations/0090_initial_passwords.sql +27 -0
- package/src/migrations/0091_account_time_zone.sql +4 -0
- package/src/migrations/0092_tools_default_on.sql +27 -0
- package/dist/platform/redact-orgs.d.ts +0 -7
- package/dist/platform/redact-orgs.js +0 -52
|
@@ -1,18 +1,25 @@
|
|
|
1
|
-
import { type ExtensionPointRef, type Logger, type ModelInfo, type ModelProvider, type ModelProviderV1 } from "@capybara-hq/plugin-sdk";
|
|
1
|
+
import { type EmbedRequest, type EmbedResult, type ExtensionManifest, type ExtensionPointRef, type Logger, type ModelInfo, type ModelKind, type ModelProvider, type ModelProviderV1, type ModelRequest, type ModelStreamEvent } from "@capybara-hq/plugin-sdk";
|
|
2
2
|
import type { Redis } from "ioredis";
|
|
3
3
|
import type { ModelRef } from "../agents/definition.js";
|
|
4
4
|
import { ApiError } from "../errors.js";
|
|
5
|
+
import { EffectiveConfigs } from "../extensions/effective-config.js";
|
|
5
6
|
import { CacheService } from "../infra/cache/cache.service.js";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
/**
|
|
7
|
+
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
8
|
+
import { ModelEnablement } from "../models/enablement.js";
|
|
9
|
+
/**
|
|
10
|
+
* Optional provider: the `listModels()` time limit (ms) instead of the config's
|
|
11
|
+
* `models.listTimeoutMs` (tests).
|
|
12
|
+
*/
|
|
9
13
|
export declare const LIST_MODELS_TIMEOUT: unique symbol;
|
|
10
14
|
/**
|
|
11
15
|
* 列表视图(后台模型页、组织模型页)里列模型失败的供应商在这么多秒内直接标 error、不再请求(Redis,多副本共享)。
|
|
12
16
|
* 只用于列表;`resolve`(运行时)照常每次请求,失败由降级梯子重试。
|
|
13
17
|
*/
|
|
14
18
|
export declare const LIST_FAILURE_TTL_SECONDS = 15;
|
|
15
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* The host view the registry needs: a subset of `ExtensionRegistry` (version, digest and
|
|
21
|
+
* `current` optional, for test doubles).
|
|
22
|
+
*/
|
|
16
23
|
export interface ProviderHost {
|
|
17
24
|
list(extensionPointName: string): {
|
|
18
25
|
plugin: string;
|
|
@@ -21,14 +28,58 @@ export interface ProviderHost {
|
|
|
21
28
|
version?: string;
|
|
22
29
|
configHash?: string;
|
|
23
30
|
}[];
|
|
31
|
+
/** The running instance: its manifest (deployment schema) and platform config. */
|
|
32
|
+
current?(plugin: string): {
|
|
33
|
+
manifest: ExtensionManifest;
|
|
34
|
+
config: unknown;
|
|
35
|
+
} | undefined;
|
|
36
|
+
}
|
|
37
|
+
/** A listed model with its kind normalised: absent means `chat`, an unknown kind is `other`. */
|
|
38
|
+
export type KernelModelInfo = Omit<ModelInfo, "kind"> & {
|
|
39
|
+
kind: ModelKind | "other";
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* A model of a view that shows disabled models too: the platform view of `listWithStatus` (`disabled`
|
|
43
|
+
* = on the platform's list) and an org's `catalog` (`disabled` = on the org's list). Absent in the
|
|
44
|
+
* enabled-only views.
|
|
45
|
+
*/
|
|
46
|
+
export type ListedModelInfo = KernelModelInfo & {
|
|
47
|
+
disabled?: boolean;
|
|
48
|
+
};
|
|
49
|
+
/** A model `resolve` returns: only `chat` and `embedding` models are callable. */
|
|
50
|
+
export type ResolvedModelInfo = Omit<ModelInfo, "kind"> & {
|
|
51
|
+
kind: "chat" | "embedding";
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* The kind a `resolve` caller needs (default `chat`: every streaming caller); `callable` accepts
|
|
55
|
+
* either callable kind (a purpose target checked against the purpose's own kind).
|
|
56
|
+
*/
|
|
57
|
+
export type ExpectedKind = "chat" | "embedding" | "callable";
|
|
58
|
+
/**
|
|
59
|
+
* A provider bound to one org's call options (`orgId` and the effective config, spec B §5.5): the
|
|
60
|
+
* kernel's callers pass only the signal. Built per `resolve`, never cached; the config stays in
|
|
61
|
+
* the closure (never on the object, so logging or serialising it shows no secret).
|
|
62
|
+
*/
|
|
63
|
+
export interface BoundProvider {
|
|
64
|
+
stream(req: ModelRequest, opts: {
|
|
65
|
+
signal: AbortSignal;
|
|
66
|
+
}): AsyncIterable<ModelStreamEvent>;
|
|
67
|
+
/** Present when the provider implements `embed`. */
|
|
68
|
+
embed?(req: EmbedRequest, opts: {
|
|
69
|
+
signal: AbortSignal;
|
|
70
|
+
}): Promise<EmbedResult>;
|
|
24
71
|
}
|
|
25
|
-
/**
|
|
72
|
+
/**
|
|
73
|
+
* 一个供应商在后台的视图:供应商名即插件名;`status: "error"` 时 `models` 为空、`error` 为内核的说明。
|
|
74
|
+
* `org_configured` (the platform view only): the platform config leaves a required overridable
|
|
75
|
+
* field empty, so each org configures the provider itself; no list.
|
|
76
|
+
*/
|
|
26
77
|
export interface ProviderStatus {
|
|
27
78
|
provider: string;
|
|
28
79
|
plugin: string;
|
|
29
|
-
status: "ok" | "error";
|
|
80
|
+
status: "ok" | "error" | "org_configured";
|
|
30
81
|
error?: string;
|
|
31
|
-
models:
|
|
82
|
+
models: ListedModelInfo[];
|
|
32
83
|
}
|
|
33
84
|
/**
|
|
34
85
|
* 供应商的 `listModels()` 失败(上游不可用等)。仍是 `agent.model_unavailable`,HTTP 调用方照常
|
|
@@ -42,61 +93,124 @@ export declare class ProviderListError extends ApiError {
|
|
|
42
93
|
/**
|
|
43
94
|
* 把 `model-provider@1` 实现包成 `@2`:
|
|
44
95
|
* - `listModels`:`parameters` 由 `capabilities.effort` 推导(为真时只有 effort 旋钮,否则为空);
|
|
96
|
+
* an `@1` model is always a chat model: `kind` and `embedding` are dropped (an `@1` provider has
|
|
97
|
+
* no `embed`); the per-call options are not passed (an `@1` provider reads `ctx.config`);
|
|
45
98
|
* - `stream`:`params.effort` 映射为 `req.effort`,其余参数丢弃(`@1` 没有对应字段);
|
|
46
|
-
* 没有 `params.effort` 时保留请求自带的 `effort
|
|
99
|
+
* 没有 `params.effort` 时保留请求自带的 `effort`;only the signal is passed.
|
|
47
100
|
*/
|
|
48
101
|
export declare function adaptModelProviderV1(impl: ModelProviderV1): ModelProvider;
|
|
49
102
|
/**
|
|
50
103
|
* 模型供应商注册表:供应商即提供 `model-provider` 能力的插件(以插件名为供应商名)。
|
|
51
104
|
* 同时支持 `model-provider@1`(经 {@link adaptModelProviderV1} 适配)与 `@2`;
|
|
52
|
-
* 同一插件两者都提供时用 `@2
|
|
53
|
-
*
|
|
54
|
-
*
|
|
105
|
+
* 同一插件两者都提供时用 `@2`。
|
|
106
|
+
*
|
|
107
|
+
* Org-bound (spec B §5.5, A §6): every list and call is made for an org with the provider's
|
|
108
|
+
* effective config there (`EffectiveConfigs.get`), passed as `{ orgId, config }`; a provider whose
|
|
109
|
+
* effective config is not valid in the org offers no models there, and neither does one the org
|
|
110
|
+
* explicitly turned off (its own extension switch row off, spec A §8; a provider with no switch row
|
|
111
|
+
* stays usable). The admin view (no org) lists with the platform config.
|
|
112
|
+
*
|
|
113
|
+
* Each list is validated per model (spec B §5.1): kinds are normalised (absent = `chat`, unknown =
|
|
114
|
+
* `other`); a chat model failing `assertValidDeclarations`, or an `embedding` model without
|
|
115
|
+
* `embedding` info or from a provider without `embed`, is dropped with a warn, the rest of the
|
|
116
|
+
* provider stays usable. Only `chat` and `embedding` models resolve.
|
|
117
|
+
*
|
|
118
|
+
* Each list (`@2`-shaped) is cached in Redis (`@Cacheable`, key
|
|
55
119
|
* `cache:capk:models:<provider>:v<major>:<plugin version>:<config digest>`, 600 s), never in
|
|
56
|
-
* process memory: every replica shares it.
|
|
120
|
+
* process memory: every replica shares it. The digest is the platform config's for every org that
|
|
121
|
+
* follows the platform (one shared list), and a per-org digest for an org's own copy.
|
|
57
122
|
*/
|
|
58
123
|
export declare class ProviderRegistry {
|
|
59
124
|
private readonly host;
|
|
125
|
+
private readonly effective;
|
|
60
126
|
readonly cacheService: CacheService;
|
|
61
127
|
private readonly kv;
|
|
128
|
+
private readonly config;
|
|
129
|
+
private readonly enablement;
|
|
62
130
|
private readonly log?;
|
|
63
|
-
/**
|
|
64
|
-
private readonly
|
|
65
|
-
constructor(host: ProviderHost, cacheService: CacheService, kv: Redis, log?: Pick<Logger, "warn"> | undefined,
|
|
66
|
-
/**
|
|
67
|
-
|
|
131
|
+
/** Overrides `models.listTimeoutMs` (tests). */
|
|
132
|
+
private readonly listTimeoutOverride?;
|
|
133
|
+
constructor(host: ProviderHost, effective: Pick<EffectiveConfigs, "get">, cacheService: CacheService, kv: Redis, config: Pick<KernelConfigService, "get">, enablement: Pick<ModelEnablement, "disabled" | "switchedOff">, log?: Pick<Logger, "warn"> | undefined,
|
|
134
|
+
/** Overrides `models.listTimeoutMs` (tests). */
|
|
135
|
+
listTimeoutOverride?: number | undefined);
|
|
68
136
|
/** `listModels()` 加时限(到时按失败处理,供应商的调用留在后台、结果丢弃)。 */
|
|
69
137
|
private listModelsWithTimeout;
|
|
70
138
|
/**
|
|
71
139
|
* Whether at least one model-provider extension is loaded on this replica (enabled, configured,
|
|
72
|
-
* set up)
|
|
73
|
-
* is down still counts (org
|
|
140
|
+
* set up) with a valid effective config in `orgId`. Read from extension state and the org's
|
|
141
|
+
* config only: never calls a vendor, so a provider whose vendor is down still counts (org
|
|
142
|
+
* readiness, web-order spec §3.8).
|
|
74
143
|
*/
|
|
75
|
-
hasProvider(): boolean
|
|
144
|
+
hasProvider(orgId: string): Promise<boolean>;
|
|
76
145
|
/** 每个插件取一个实现(`@2` 优先),按插件首次出现的顺序;不支持的主版本记 warn 后忽略。 */
|
|
77
146
|
private providers;
|
|
147
|
+
/**
|
|
148
|
+
* The call options and list digest of `p` for `orgId`, or for the platform when `orgId` is
|
|
149
|
+
* undefined (the admin view). An org: its effective config (not valid -> `needs_config`); the
|
|
150
|
+
* platform's digest while it follows the platform, a per-org one for its copy. The platform: its
|
|
151
|
+
* own config (a required overridable field left empty -> `org_configured`). `off`: the
|
|
152
|
+
* extensions the org explicitly turned off (`ModelEnablement.switchedOff`) -> `switched_off`.
|
|
153
|
+
*/
|
|
154
|
+
private target;
|
|
78
155
|
private models;
|
|
79
156
|
/** The provider's validated model list, cached under `key` (see {@link modelsKey}). */
|
|
80
157
|
private validatedModels;
|
|
81
|
-
/**
|
|
82
|
-
|
|
158
|
+
/** One warn per (provider, model, config digest) within {@link DROPPED_WARN_TTL_SECONDS}. */
|
|
159
|
+
private warnDropped;
|
|
160
|
+
/**
|
|
161
|
+
* 每个供应商及其模型(按插件加载顺序),for `orgId`:列模型失败或在该组织需要配置的供应商跳过。Only
|
|
162
|
+
* enabled models (neither the platform nor the org disabled them, spec B §5.3), optionally of
|
|
163
|
+
* one `kind`.
|
|
164
|
+
*/
|
|
165
|
+
list(orgId: string, opts?: {
|
|
166
|
+
kind?: ModelKind | "other";
|
|
167
|
+
}): Promise<{
|
|
83
168
|
provider: string;
|
|
84
|
-
models:
|
|
169
|
+
models: KernelModelInfo[];
|
|
85
170
|
}[]>;
|
|
86
171
|
/**
|
|
87
|
-
*
|
|
88
|
-
*
|
|
172
|
+
* An org's catalog (the org settings page, spec B §5.3): every provider as in
|
|
173
|
+
* {@link listWithStatus} for the org, with every model the platform left on, each carrying
|
|
174
|
+
* `disabled` for the org's own list. Reads the same cached lists (no extra provider call).
|
|
89
175
|
*/
|
|
90
|
-
|
|
176
|
+
catalog(orgId: string): Promise<ProviderStatus[]>;
|
|
91
177
|
/**
|
|
92
|
-
*
|
|
93
|
-
*
|
|
178
|
+
* 每个已安装供应商及其状态(按插件加载顺序),for `orgId` (enabled models only), or the platform
|
|
179
|
+
* view when undefined (`/admin/models`: every model, `disabled` from the platform's list only).
|
|
180
|
+
* See {@link statuses} for the statuses.
|
|
181
|
+
*/
|
|
182
|
+
listWithStatus(orgId?: string): Promise<ProviderStatus[]>;
|
|
183
|
+
/**
|
|
184
|
+
* 每个已安装供应商的完整列表与状态,for `orgId` or the platform: 列模型失败(含超过
|
|
185
|
+
* `models.listTimeoutMs`)的标 `error`、`models` 为空,不影响其他供应商;列模型失败的在
|
|
186
|
+
* {@link LIST_FAILURE_TTL_SECONDS} 秒内不再请求。An org where the provider needs configuration gets
|
|
187
|
+
* `error`; the platform view of a provider whose platform config leaves a required overridable
|
|
188
|
+
* field empty gets `org_configured`. `error` 只是内核自己的英文说明(不透出上游错误原文,原文记 warn
|
|
189
|
+
* 日志)。No disabled list applied.
|
|
190
|
+
*/
|
|
191
|
+
private statuses;
|
|
192
|
+
/**
|
|
193
|
+
* 解析模型引用 for `orgId`,返回绑定到该组织调用选项的供应商与模型信息。
|
|
194
|
+
* 供应商未安装、在该组织需要配置、模型不存在(或被丢弃)、不是 `opts.kind`(default `chat`: a
|
|
195
|
+
* streaming caller never gets an embedding model)或被平台 / 该组织停用 → `agent.model_unavailable`;
|
|
94
196
|
* 供应商 `listModels()` 失败 → `ProviderListError`(同一错误码,运行时视为可重试)。
|
|
95
197
|
*/
|
|
96
|
-
resolve(ref: ModelRef
|
|
97
|
-
|
|
98
|
-
|
|
198
|
+
resolve(orgId: string, ref: ModelRef, opts?: {
|
|
199
|
+
kind?: ExpectedKind;
|
|
200
|
+
}): Promise<{
|
|
201
|
+
provider: BoundProvider;
|
|
202
|
+
info: ResolvedModelInfo;
|
|
99
203
|
}>;
|
|
204
|
+
/**
|
|
205
|
+
* The model's info in the platform view (deployment-level settings such as a purpose's
|
|
206
|
+
* deployment default; no call is ever made there), by {@link resolve}'s rules. A provider each
|
|
207
|
+
* org configures itself has no platform list: `agent.model_unavailable`. Only the platform's
|
|
208
|
+
* disabled list applies.
|
|
209
|
+
*/
|
|
210
|
+
platformInfo(ref: ModelRef, opts?: {
|
|
211
|
+
kind?: ExpectedKind;
|
|
212
|
+
}): Promise<ResolvedModelInfo>;
|
|
213
|
+
private lookup;
|
|
100
214
|
}
|
|
101
215
|
/** The model provider registry (one instance; the models and agents domains read it). */
|
|
102
216
|
export declare class ProvidersModule {
|