@clinebot/core 0.0.36 → 0.0.37
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/ClineCore.d.ts +312 -3
- package/dist/ClineCore.d.ts.map +1 -1
- package/dist/account/cline-account-service.d.ts.map +1 -1
- package/dist/cron/cron-event-ingress.d.ts +38 -0
- package/dist/cron/cron-event-ingress.d.ts.map +1 -0
- package/dist/cron/cron-materializer.d.ts +36 -0
- package/dist/cron/cron-materializer.d.ts.map +1 -0
- package/dist/cron/cron-reconciler.d.ts +62 -0
- package/dist/cron/cron-reconciler.d.ts.map +1 -0
- package/dist/cron/cron-report-writer.d.ts +41 -0
- package/dist/cron/cron-report-writer.d.ts.map +1 -0
- package/dist/cron/cron-runner.d.ts +43 -0
- package/dist/cron/cron-runner.d.ts.map +1 -0
- package/dist/cron/cron-schema.d.ts +3 -0
- package/dist/cron/cron-schema.d.ts.map +1 -0
- package/dist/cron/cron-service.d.ts +57 -0
- package/dist/cron/cron-service.d.ts.map +1 -0
- package/dist/cron/cron-spec-parser.d.ts +27 -0
- package/dist/cron/cron-spec-parser.d.ts.map +1 -0
- package/dist/cron/cron-watcher.d.ts +23 -0
- package/dist/cron/cron-watcher.d.ts.map +1 -0
- package/dist/cron/scheduler.d.ts +3 -1
- package/dist/cron/scheduler.d.ts.map +1 -1
- package/dist/cron/sqlite-cron-store.d.ts +230 -0
- package/dist/cron/sqlite-cron-store.d.ts.map +1 -0
- package/dist/extensions/plugin/plugin-config-loader.d.ts +7 -1
- package/dist/extensions/plugin/plugin-config-loader.d.ts.map +1 -1
- package/dist/extensions/plugin/plugin-loader.d.ts +10 -6
- package/dist/extensions/plugin/plugin-loader.d.ts.map +1 -1
- package/dist/extensions/plugin/plugin-sandbox.d.ts +7 -1
- package/dist/extensions/plugin/plugin-sandbox.d.ts.map +1 -1
- package/dist/extensions/plugin-sandbox-bootstrap.js +236 -275
- package/dist/extensions/tools/constants.d.ts +1 -0
- package/dist/extensions/tools/constants.d.ts.map +1 -1
- package/dist/extensions/tools/definitions.d.ts +2 -3
- package/dist/extensions/tools/definitions.d.ts.map +1 -1
- package/dist/extensions/tools/executors/editor.d.ts.map +1 -1
- package/dist/extensions/tools/helpers.d.ts +1 -0
- package/dist/extensions/tools/helpers.d.ts.map +1 -1
- package/dist/extensions/tools/index.d.ts +1 -2
- package/dist/extensions/tools/index.d.ts.map +1 -1
- package/dist/extensions/tools/presets.d.ts +1 -1
- package/dist/extensions/tools/schemas.d.ts +25 -3
- package/dist/extensions/tools/schemas.d.ts.map +1 -1
- package/dist/extensions/tools/team/delegated-agent.d.ts +2 -2
- package/dist/extensions/tools/team/delegated-agent.d.ts.map +1 -1
- package/dist/extensions/tools/team/multi-agent.d.ts +7 -3
- package/dist/extensions/tools/team/multi-agent.d.ts.map +1 -1
- package/dist/extensions/tools/team/team-tools.d.ts.map +1 -1
- package/dist/extensions/tools/types.d.ts +0 -5
- package/dist/extensions/tools/types.d.ts.map +1 -1
- package/dist/hooks/hook-bridge.d.ts +118 -0
- package/dist/hooks/hook-bridge.d.ts.map +1 -0
- package/dist/hooks/hook-file-hooks.d.ts +2 -1
- package/dist/hooks/hook-file-hooks.d.ts.map +1 -1
- package/dist/hooks/hook-registry.d.ts +16 -0
- package/dist/hooks/hook-registry.d.ts.map +1 -0
- package/dist/hub/browser-websocket.d.ts.map +1 -1
- package/dist/hub/client.d.ts +7 -1
- package/dist/hub/client.d.ts.map +1 -1
- package/dist/hub/daemon-entry.js +721 -461
- package/dist/hub/daemon.d.ts.map +1 -1
- package/dist/hub/defaults.d.ts +8 -4
- package/dist/hub/defaults.d.ts.map +1 -1
- package/dist/hub/index.js +665 -415
- package/dist/hub/runtime-handlers.d.ts.map +1 -1
- package/dist/hub/server.d.ts +18 -0
- package/dist/hub/server.d.ts.map +1 -1
- package/dist/hub/session-client.d.ts +3 -0
- package/dist/hub/session-client.d.ts.map +1 -1
- package/dist/hub/start-shared-server.d.ts.map +1 -1
- package/dist/hub/ui-client.d.ts +1 -0
- package/dist/hub/ui-client.d.ts.map +1 -1
- package/dist/index.d.ts +9 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +756 -467
- package/dist/llms/cline-recommended-models.d.ts +20 -0
- package/dist/llms/cline-recommended-models.d.ts.map +1 -0
- package/dist/llms/handler-factory.d.ts +16 -0
- package/dist/llms/handler-factory.d.ts.map +1 -0
- package/dist/llms/provider-defaults.d.ts.map +1 -1
- package/dist/llms/provider-settings.d.ts +45 -2
- package/dist/llms/provider-settings.d.ts.map +1 -1
- package/dist/llms/runtime-registry.d.ts.map +1 -1
- package/dist/runtime/agent-config-adapter.d.ts +148 -0
- package/dist/runtime/agent-config-adapter.d.ts.map +1 -0
- package/dist/runtime/agent-runtime-config-builder.d.ts +96 -0
- package/dist/runtime/agent-runtime-config-builder.d.ts.map +1 -0
- package/dist/runtime/history.d.ts +6 -0
- package/dist/runtime/history.d.ts.map +1 -1
- package/dist/runtime/host.d.ts.map +1 -1
- package/dist/runtime/loop-detection.d.ts +59 -0
- package/dist/runtime/loop-detection.d.ts.map +1 -0
- package/dist/runtime/mistake-tracker.d.ts +69 -0
- package/dist/runtime/mistake-tracker.d.ts.map +1 -0
- package/dist/runtime/runtime-builder.d.ts.map +1 -1
- package/dist/runtime/runtime-event-adapter.d.ts +102 -0
- package/dist/runtime/runtime-event-adapter.d.ts.map +1 -0
- package/dist/runtime/runtime-host.d.ts +28 -3
- package/dist/runtime/runtime-host.d.ts.map +1 -1
- package/dist/runtime/session-runtime-orchestrator.d.ts +261 -0
- package/dist/runtime/session-runtime-orchestrator.d.ts.map +1 -0
- package/dist/runtime/session-runtime.d.ts +16 -3
- package/dist/runtime/session-runtime.d.ts.map +1 -1
- package/dist/runtime/user-input-builder.d.ts +24 -0
- package/dist/runtime/user-input-builder.d.ts.map +1 -0
- package/dist/services/index.js +28 -0
- package/dist/services/local-runtime-bootstrap.d.ts.map +1 -1
- package/dist/services/plugin-tools.d.ts.map +1 -1
- package/dist/services/providers/local-provider-registry.d.ts +197 -21
- package/dist/services/providers/local-provider-registry.d.ts.map +1 -1
- package/dist/services/providers/local-provider-service.d.ts +3 -1
- package/dist/services/providers/local-provider-service.d.ts.map +1 -1
- package/dist/services/session-data.d.ts.map +1 -1
- package/dist/services/session-telemetry.d.ts +7 -2
- package/dist/services/session-telemetry.d.ts.map +1 -1
- package/dist/services/storage/file-team-store.d.ts.map +1 -1
- package/dist/services/storage/provider-settings-legacy-migration.d.ts.map +1 -1
- package/dist/services/storage/provider-settings-manager.d.ts +1 -0
- package/dist/services/storage/provider-settings-manager.d.ts.map +1 -1
- package/dist/services/storage/sqlite-team-store.d.ts.map +1 -1
- package/dist/session/conversation-store.d.ts +30 -0
- package/dist/session/conversation-store.d.ts.map +1 -0
- package/dist/session/message-builder.d.ts +65 -0
- package/dist/session/message-builder.d.ts.map +1 -0
- package/dist/session/session-manifest.d.ts +1 -1
- package/dist/transports/hub.d.ts +14 -3
- package/dist/transports/hub.d.ts.map +1 -1
- package/dist/transports/local.d.ts +14 -4
- package/dist/transports/local.d.ts.map +1 -1
- package/dist/transports/remote.d.ts.map +1 -1
- package/dist/types/chat-schema.d.ts +5 -5
- package/dist/types/config.d.ts +9 -0
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/events.d.ts +7 -6
- package/dist/types/events.d.ts.map +1 -1
- package/dist/types/provider-settings.d.ts +2 -2
- package/dist/types/provider-settings.d.ts.map +1 -1
- package/dist/types/session.d.ts +5 -2
- package/dist/types/session.d.ts.map +1 -1
- package/dist/types.d.ts +4 -4
- package/dist/types.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/ClineCore.ts +691 -6
- package/src/account/cline-account-service.ts +44 -6
- package/src/cron/cron-event-ingress.ts +357 -0
- package/src/cron/cron-materializer.ts +97 -0
- package/src/cron/cron-reconciler.ts +241 -0
- package/src/cron/cron-report-writer.ts +153 -0
- package/src/cron/cron-runner.ts +495 -0
- package/src/cron/cron-schema.ts +127 -0
- package/src/cron/cron-service.ts +163 -0
- package/src/cron/cron-spec-parser.ts +489 -0
- package/src/cron/cron-watcher.ts +102 -0
- package/src/cron/index.ts +10 -0
- package/src/cron/scheduler.ts +141 -6
- package/src/cron/sqlite-cron-store.ts +1286 -0
- package/src/extensions/plugin/plugin-config-loader.ts +21 -1
- package/src/extensions/plugin/plugin-loader.ts +25 -9
- package/src/extensions/plugin/plugin-sandbox-bootstrap.ts +151 -1
- package/src/extensions/plugin/plugin-sandbox.ts +131 -7
- package/src/extensions/tools/constants.ts +2 -0
- package/src/extensions/tools/definitions.ts +31 -22
- package/src/extensions/tools/executors/editor.ts +4 -3
- package/src/extensions/tools/helpers.ts +24 -0
- package/src/extensions/tools/index.ts +1 -2
- package/src/extensions/tools/presets.ts +1 -1
- package/src/extensions/tools/schemas.ts +13 -18
- package/src/extensions/tools/team/delegated-agent.ts +8 -3
- package/src/extensions/tools/team/multi-agent.ts +135 -19
- package/src/extensions/tools/team/team-tools.ts +151 -91
- package/src/extensions/tools/types.ts +0 -6
- package/src/hooks/hook-bridge.ts +489 -0
- package/src/hooks/hook-file-hooks.ts +58 -3
- package/src/hooks/hook-registry.ts +257 -0
- package/src/hub/browser-websocket.ts +26 -4
- package/src/hub/client.ts +72 -13
- package/src/hub/daemon-entry.ts +35 -0
- package/src/hub/daemon.ts +117 -14
- package/src/hub/defaults.ts +39 -12
- package/src/hub/runtime-handlers.ts +4 -3
- package/src/hub/server.ts +506 -77
- package/src/hub/session-client.ts +43 -1
- package/src/hub/start-shared-server.ts +3 -0
- package/src/hub/ui-client.ts +4 -0
- package/src/index.ts +46 -1
- package/src/llms/cline-recommended-models.ts +167 -0
- package/src/llms/handler-factory.ts +56 -0
- package/src/llms/provider-defaults.ts +17 -1
- package/src/llms/provider-settings.ts +48 -1
- package/src/llms/runtime-registry.ts +1 -0
- package/src/runtime/agent-config-adapter.ts +636 -0
- package/src/runtime/agent-runtime-config-builder.ts +205 -0
- package/src/runtime/error-feedback.ts +142 -0
- package/src/runtime/history.ts +137 -0
- package/src/runtime/host.ts +22 -0
- package/src/runtime/loop-detection.ts +162 -0
- package/src/runtime/mistake-tracker.ts +221 -0
- package/src/runtime/runtime-builder.ts +61 -5
- package/src/runtime/runtime-event-adapter.ts +412 -0
- package/src/runtime/runtime-host.ts +45 -1
- package/src/runtime/session-runtime-orchestrator.ts +1253 -0
- package/src/runtime/session-runtime.ts +16 -2
- package/src/runtime/user-input-builder.ts +167 -0
- package/src/services/local-runtime-bootstrap.ts +128 -22
- package/src/services/plugin-tools.ts +1 -0
- package/src/services/providers/local-provider-registry.ts +273 -57
- package/src/services/providers/local-provider-service.ts +67 -7
- package/src/services/session-data.ts +16 -14
- package/src/services/session-telemetry.ts +6 -15
- package/src/services/storage/file-team-store.ts +1 -5
- package/src/services/storage/provider-settings-legacy-migration.ts +8 -47
- package/src/services/storage/provider-settings-manager.ts +16 -1
- package/src/services/storage/sqlite-team-store.ts +1 -5
- package/src/session/conversation-store.ts +77 -0
- package/src/session/message-builder.ts +941 -0
- package/src/transports/hub.ts +458 -33
- package/src/transports/local.ts +296 -65
- package/src/transports/remote.ts +1 -0
- package/src/types/config.ts +9 -0
- package/src/types/events.ts +8 -6
- package/src/types/index.ts +3 -0
- package/src/types/provider-settings.ts +8 -1
- package/src/types/session.ts +5 -2
- package/src/types.ts +15 -1
- package/dist/cron/index.d.ts +0 -6
- package/dist/cron/index.d.ts.map +0 -1
- package/dist/services/telemetry/index.js +0 -28
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ProviderSettingsManager } from "../services/storage/provider-settings-manager";
|
|
2
|
+
export interface ClineRecommendedModel {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
tags: string[];
|
|
7
|
+
}
|
|
8
|
+
export interface ClineRecommendedModelsData {
|
|
9
|
+
recommended: ClineRecommendedModel[];
|
|
10
|
+
free: ClineRecommendedModel[];
|
|
11
|
+
}
|
|
12
|
+
export interface FetchClineRecommendedModelsOptions {
|
|
13
|
+
baseUrl?: string;
|
|
14
|
+
fetchImpl?: typeof fetch;
|
|
15
|
+
providerSettingsManager?: Pick<ProviderSettingsManager, "getProviderSettings">;
|
|
16
|
+
timeoutMs?: number;
|
|
17
|
+
}
|
|
18
|
+
export declare const FALLBACK_CLINE_RECOMMENDED_MODELS: ClineRecommendedModelsData;
|
|
19
|
+
export declare function fetchClineRecommendedModels(options?: FetchClineRecommendedModelsOptions): Promise<ClineRecommendedModelsData>;
|
|
20
|
+
//# sourceMappingURL=cline-recommended-models.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cline-recommended-models.d.ts","sourceRoot":"","sources":["../../src/llms/cline-recommended-models.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,+CAA+C,CAAC;AAExF,MAAM,WAAW,qBAAqB;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,EAAE,CAAC;CACf;AAED,MAAM,WAAW,0BAA0B;IAC1C,WAAW,EAAE,qBAAqB,EAAE,CAAC;IACrC,IAAI,EAAE,qBAAqB,EAAE,CAAC;CAC9B;AAED,MAAM,WAAW,kCAAkC;IAClD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;IACzB,uBAAuB,CAAC,EAAE,IAAI,CAC7B,uBAAuB,EACvB,qBAAqB,CACrB,CAAC;IACF,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAKD,eAAO,MAAM,iCAAiC,EAAE,0BAyC/C,CAAC;AA8EF,wBAAsB,2BAA2B,CAChD,OAAO,GAAE,kCAAuC,GAC9C,OAAO,CAAC,0BAA0B,CAAC,CAkBrC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build a concrete `LlmsProviders.ApiHandler` from an `AgentConfig`.
|
|
3
|
+
*
|
|
4
|
+
* @see PLAN.md §3.1 — moved from `packages/agents/src/utils/config-helpers.ts` lines 15–55.
|
|
5
|
+
* @see PLAN.md §3.2.1 — `AgentConfig → AgentRuntimeConfig` mapping for
|
|
6
|
+
* the `model` field.
|
|
7
|
+
*
|
|
8
|
+
* Pure port. Core calls this once per session (and again on
|
|
9
|
+
* `updateConnection`) to produce the `AgentModel` adapter handed to
|
|
10
|
+
* `new AgentRuntime({ model, ... })`.
|
|
11
|
+
*/
|
|
12
|
+
import * as LlmsProviders from "@clinebot/llms";
|
|
13
|
+
import type { AgentConfig, BasicLogger } from "@clinebot/shared";
|
|
14
|
+
export declare function resolveKnownModelsFromConfig(config: AgentConfig): Record<string, LlmsProviders.ModelInfo> | undefined;
|
|
15
|
+
export declare function createHandlerFromConfig(config: AgentConfig, logger: BasicLogger | undefined): LlmsProviders.ApiHandler;
|
|
16
|
+
//# sourceMappingURL=handler-factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler-factory.d.ts","sourceRoot":"","sources":["../../src/llms/handler-factory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,aAAa,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEjE,wBAAgB,4BAA4B,CAC3C,MAAM,EAAE,WAAW,GACjB,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,SAAS,CAAC,GAAG,SAAS,CAYrD;AAED,wBAAgB,uBAAuB,CACtC,MAAM,EAAE,WAAW,EACnB,MAAM,EAAE,WAAW,GAAG,SAAS,GAC7B,aAAa,CAAC,UAAU,CAqB1B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider-defaults.d.ts","sourceRoot":"","sources":["../../src/llms/provider-defaults.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAE7D,OAAO,KAA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E,CAAC;IAChD,GAAG,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACxB,MAAM,EAAE,IAAI,CAAC,cAAc,CAAC;IAC5B,QAAQ,CAAC,EAAE,IAAI,CAAC,gBAAgB,CAAC;CACjC;AAkED,MAAM,WAAW,gBAAgB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACxC,YAAY,CAAC,EAAE,kBAAkB,EAAE,CAAC;CACpC;AAmBD,eAAO,MAAM,0BAA0B,gCAAgC,CAAC;AAwaxE,wBAAsB,oBAAoB,CACzC,OAAO,GAAE,IAAI,CAAC,kBAAkB,EAAE,KAAK,GAAG,YAAY,CAAM,GAC1D,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,CA0BpD;AAED,wBAAgB,2BAA2B,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAS9D;AAED,wBAAgB,8BAA8B,IAAI,IAAI,CAGrD;AAiBD,eAAO,MAAM,2BAA2B,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CACP,CAAC;AAEnE,wBAAgB,iBAAiB,CAChC,UAAU,EAAE,MAAM,GAChB,gBAAgB,GAAG,SAAS,CAY9B;AAED,wBAAsB,qBAAqB,CAC1C,UAAU,EAAE,MAAM,EAClB,YAAY,CAAC,EAAE,kBAAkB,EACjC,MAAM,CAAC,EAAE,cAAc,GACrB,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC,CAmCvC"}
|
|
@@ -14,6 +14,27 @@ export declare const isBuiltInProviderId: typeof Llms.isBuiltInProviderId;
|
|
|
14
14
|
export declare const normalizeProviderId: typeof Llms.normalizeProviderId;
|
|
15
15
|
export type ProviderDefaultsConfig = ProviderDefaults;
|
|
16
16
|
export declare const ProviderIdSchema: z.ZodString;
|
|
17
|
+
export declare const ProviderProtocolSchema: z.ZodEnum<{
|
|
18
|
+
"openai-responses": "openai-responses";
|
|
19
|
+
anthropic: "anthropic";
|
|
20
|
+
gemini: "gemini";
|
|
21
|
+
"openai-chat": "openai-chat";
|
|
22
|
+
"openai-r1": "openai-r1";
|
|
23
|
+
"ai-sdk": "ai-sdk";
|
|
24
|
+
}>;
|
|
25
|
+
export declare const ProviderClientSchema: z.ZodEnum<{
|
|
26
|
+
custom: "custom";
|
|
27
|
+
anthropic: "anthropic";
|
|
28
|
+
gemini: "gemini";
|
|
29
|
+
"openai-r1": "openai-r1";
|
|
30
|
+
"ai-sdk": "ai-sdk";
|
|
31
|
+
"ai-sdk-community": "ai-sdk-community";
|
|
32
|
+
openai: "openai";
|
|
33
|
+
"openai-compatible": "openai-compatible";
|
|
34
|
+
bedrock: "bedrock";
|
|
35
|
+
fetch: "fetch";
|
|
36
|
+
vertex: "vertex";
|
|
37
|
+
}>;
|
|
17
38
|
export declare const AuthSettingsSchema: z.ZodObject<{
|
|
18
39
|
apiKey: z.ZodOptional<z.ZodString>;
|
|
19
40
|
accessToken: z.ZodOptional<z.ZodString>;
|
|
@@ -104,6 +125,28 @@ export declare const ProviderSettingsSchema: z.ZodObject<{
|
|
|
104
125
|
accountId: z.ZodOptional<z.ZodString>;
|
|
105
126
|
}, z.core.$strip>>;
|
|
106
127
|
model: z.ZodOptional<z.ZodString>;
|
|
128
|
+
protocol: z.ZodOptional<z.ZodEnum<{
|
|
129
|
+
"openai-responses": "openai-responses";
|
|
130
|
+
anthropic: "anthropic";
|
|
131
|
+
gemini: "gemini";
|
|
132
|
+
"openai-chat": "openai-chat";
|
|
133
|
+
"openai-r1": "openai-r1";
|
|
134
|
+
"ai-sdk": "ai-sdk";
|
|
135
|
+
}>>;
|
|
136
|
+
client: z.ZodOptional<z.ZodEnum<{
|
|
137
|
+
custom: "custom";
|
|
138
|
+
anthropic: "anthropic";
|
|
139
|
+
gemini: "gemini";
|
|
140
|
+
"openai-r1": "openai-r1";
|
|
141
|
+
"ai-sdk": "ai-sdk";
|
|
142
|
+
"ai-sdk-community": "ai-sdk-community";
|
|
143
|
+
openai: "openai";
|
|
144
|
+
"openai-compatible": "openai-compatible";
|
|
145
|
+
bedrock: "bedrock";
|
|
146
|
+
fetch: "fetch";
|
|
147
|
+
vertex: "vertex";
|
|
148
|
+
}>>;
|
|
149
|
+
routingProviderId: z.ZodOptional<z.ZodString>;
|
|
107
150
|
maxTokens: z.ZodOptional<z.ZodNumber>;
|
|
108
151
|
contextWindow: z.ZodOptional<z.ZodNumber>;
|
|
109
152
|
baseUrl: z.ZodOptional<z.ZodString>;
|
|
@@ -171,13 +214,13 @@ export declare const ProviderSettingsSchema: z.ZodObject<{
|
|
|
171
214
|
international: "international";
|
|
172
215
|
}>>;
|
|
173
216
|
capabilities: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
217
|
+
reasoning: "reasoning";
|
|
174
218
|
tools: "tools";
|
|
175
219
|
streaming: "streaming";
|
|
176
220
|
"prompt-cache": "prompt-cache";
|
|
177
|
-
reasoning: "reasoning";
|
|
178
221
|
"computer-use": "computer-use";
|
|
179
|
-
vision: "vision";
|
|
180
222
|
oauth: "oauth";
|
|
223
|
+
vision: "vision";
|
|
181
224
|
}>>>;
|
|
182
225
|
modelCatalog: z.ZodOptional<z.ZodObject<{
|
|
183
226
|
loadLatestOnInit: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider-settings.d.ts","sourceRoot":"","sources":["../../src/llms/provider-settings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,OAAO,EAEN,KAAK,gBAAgB,EACrB,MAAM,qBAAqB,CAAC;AAE7B,MAAM,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;AACvC,MAAM,MAAM,cAAc,GAAG,I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AM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO;IAI/D,OAAO,CAAC,WAAW;CAyBnB;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAEzD"}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cross-shape adapters between the **legacy host API** types
|
|
3
|
+
* (`ApiHandler`, `Tool`, `MessageWithMetadata`) and the **new
|
|
4
|
+
* runtime contract** types (`AgentModel`, `AgentTool`,
|
|
5
|
+
* `AgentMessage`) consumed by `AgentRuntime`.
|
|
6
|
+
*
|
|
7
|
+
* @see PLAN.md §3.1 — pure adapters; introduced alongside the core
|
|
8
|
+
* runtime port.
|
|
9
|
+
* @see PLAN.md §3.2.1 — consumed by `createAgentRuntimeConfig` to
|
|
10
|
+
* populate the `model`, `tools`, and
|
|
11
|
+
* `initialMessages` fields.
|
|
12
|
+
*
|
|
13
|
+
* These functions are intentionally **pure** (stateless adapters —
|
|
14
|
+
* they allocate fresh closures / arrays on every call and hold no
|
|
15
|
+
* internal state). Any state a consumer needs (e.g. an `AbortSignal`
|
|
16
|
+
* or a conversation id for `ToolContext.conversationId`) is injected
|
|
17
|
+
* per-call via the second-arg options object.
|
|
18
|
+
*/
|
|
19
|
+
import type { ApiHandler, ApiStreamChunk, ToolDefinition } from "@clinebot/llms";
|
|
20
|
+
import type { AgentMessage, AgentModel, AgentModelEvent, AgentModelRequest, AgentTool, Message, MessageWithMetadata, Tool } from "@clinebot/shared";
|
|
21
|
+
/**
|
|
22
|
+
* Context describing the model the `ApiHandler` talks to. This is
|
|
23
|
+
* used to populate `AgentMessage.modelInfo` on assistant messages
|
|
24
|
+
* emitted by the runtime. Matches PLAN.md §3.2.1 —
|
|
25
|
+
* `messageModelInfo = { id: modelId, provider: providerId, family:
|
|
26
|
+
* providerConfig?.family }`.
|
|
27
|
+
*/
|
|
28
|
+
export interface ApiHandlerAgentModelOptions {
|
|
29
|
+
/** Optional provider-family hint (e.g. `"claude-3.5"`). Attached as metadata. */
|
|
30
|
+
readonly family?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Optional abort-signal factory. When provided, the returned
|
|
33
|
+
* `AgentModel.stream()` installs the signal on the handler via
|
|
34
|
+
* `handler.setAbortSignal()` before each call, and threads
|
|
35
|
+
* `request.signal` through for per-turn abort semantics.
|
|
36
|
+
*/
|
|
37
|
+
readonly getAbortSignal?: () => AbortSignal | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Last-mile message preparation before the legacy handler builds a provider
|
|
40
|
+
* request. SessionRuntime uses this to apply API-safe normalization,
|
|
41
|
+
* tool-result truncation, and stale read-result rewriting with its
|
|
42
|
+
* session-owned MessageBuilder.
|
|
43
|
+
*/
|
|
44
|
+
readonly prepareMessages?: (messages: Message[]) => Message[] | Promise<Message[]>;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Build an `AgentModel` adapter around an existing `ApiHandler`.
|
|
48
|
+
*
|
|
49
|
+
* The returned adapter:
|
|
50
|
+
*
|
|
51
|
+
* 1. Converts `AgentModelRequest.messages` (`AgentMessage[]`) back
|
|
52
|
+
* into `LlmsProviders.Message[]` via
|
|
53
|
+
* {@link agentMessagesToMessages}.
|
|
54
|
+
* 2. Converts `AgentModelRequest.tools`
|
|
55
|
+
* (`AgentToolDefinition[]`) to `LlmsProviders.ToolDefinition[]`.
|
|
56
|
+
* 3. Invokes `handler.createMessage(systemPrompt, messages, tools)`.
|
|
57
|
+
* 4. Iterates the returned `ApiStream` and yields
|
|
58
|
+
* `AgentModelEvent`s produced by {@link apiStreamChunkToAgentModelEvent}.
|
|
59
|
+
*/
|
|
60
|
+
export declare function apiHandlerToAgentModel(handler: ApiHandler, options?: ApiHandlerAgentModelOptions): AgentModel;
|
|
61
|
+
/**
|
|
62
|
+
* Translate an `ApiStream` (async generator of `ApiStreamChunk`)
|
|
63
|
+
* into an async iterable of `AgentModelEvent`. Exposed for tests;
|
|
64
|
+
* production callers go through {@link apiHandlerToAgentModel}.
|
|
65
|
+
*/
|
|
66
|
+
export declare function translateApiStream(stream: AsyncIterable<ApiStreamChunk>): AsyncIterable<AgentModelEvent>;
|
|
67
|
+
/**
|
|
68
|
+
* Map a single `ApiStreamChunk` to the corresponding
|
|
69
|
+
* `AgentModelEvent`. Returns `undefined` for chunks that carry no
|
|
70
|
+
* runtime-observable payload (currently none — but the hook exists
|
|
71
|
+
* so we can silently drop future additions without type breakage).
|
|
72
|
+
*/
|
|
73
|
+
export declare function apiStreamChunkToAgentModelEvent(chunk: ApiStreamChunk): AgentModelEvent | undefined;
|
|
74
|
+
/**
|
|
75
|
+
* Options threaded into every adapted tool's `ToolContext`.
|
|
76
|
+
*/
|
|
77
|
+
export interface ToolAdapterOptions {
|
|
78
|
+
/**
|
|
79
|
+
* Conversation id bound to every `ToolContext.conversationId`
|
|
80
|
+
* the tool's `execute()` receives. The new runtime scopes tools
|
|
81
|
+
* by `AgentToolContext.agentId`/`.runId`; the legacy `ToolContext`
|
|
82
|
+
* requires `conversationId` separately, so the caller
|
|
83
|
+
* (`SessionRuntime`) supplies it once at adapter-construction
|
|
84
|
+
* time.
|
|
85
|
+
*/
|
|
86
|
+
readonly conversationId: string;
|
|
87
|
+
/**
|
|
88
|
+
* Optional metadata merged into every tool execution
|
|
89
|
+
* (`AgentConfig.toolContextMetadata` equivalent).
|
|
90
|
+
*/
|
|
91
|
+
readonly metadata?: Record<string, unknown>;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Adapt a legacy `Tool<TInput, TOutput>` to the new
|
|
95
|
+
* `AgentTool<TInput, TOutput>`.
|
|
96
|
+
*
|
|
97
|
+
* - name/description/inputSchema flow through verbatim;
|
|
98
|
+
* - `execute(input, AgentToolContext)` is wrapped so the legacy
|
|
99
|
+
* signature `execute(input, ToolContext, onChange)` receives the
|
|
100
|
+
* correct fields and the return value is boxed into an
|
|
101
|
+
* `AgentToolResult`.
|
|
102
|
+
*/
|
|
103
|
+
export declare function toolToAgentTool<TInput, TOutput>(tool: Tool<TInput, TOutput>, options: ToolAdapterOptions): AgentTool<TInput, TOutput>;
|
|
104
|
+
/**
|
|
105
|
+
* Convenience bulk-adapter for `AgentConfig.tools`.
|
|
106
|
+
*/
|
|
107
|
+
export declare function toolsToAgentTools(tools: readonly Tool[], options: ToolAdapterOptions): AgentTool[];
|
|
108
|
+
/**
|
|
109
|
+
* Normalize a single `MessageWithMetadata` into an `AgentMessage`.
|
|
110
|
+
*
|
|
111
|
+
* Role mapping: the legacy `MessageRole` is `"user" | "assistant"`.
|
|
112
|
+
* `tool_result` content blocks on user messages are hoisted into a
|
|
113
|
+
* dedicated `AgentMessage` with role `"tool"` — matching how the new
|
|
114
|
+
* runtime's tool executor emits tool messages
|
|
115
|
+
* (`packages/agents/src/agent-runtime.ts` tool-finished path).
|
|
116
|
+
*/
|
|
117
|
+
export declare function messageToAgentMessages(message: MessageWithMetadata): AgentMessage[];
|
|
118
|
+
/**
|
|
119
|
+
* Bulk-adapter: `MessageWithMetadata[]` → `AgentMessage[]`. A single
|
|
120
|
+
* legacy message with both text and tool-result blocks may expand
|
|
121
|
+
* into multiple agent messages (see {@link messageToAgentMessages}).
|
|
122
|
+
*/
|
|
123
|
+
export declare function messagesToAgentMessages(messages: readonly MessageWithMetadata[]): AgentMessage[];
|
|
124
|
+
/**
|
|
125
|
+
* Reverse adapter: `AgentMessage` → `MessageWithMetadata`. Best-effort
|
|
126
|
+
* preservation of id/metadata/modelInfo/metrics; tool-message
|
|
127
|
+
* tool-result parts are rendered as `tool_result` content blocks on
|
|
128
|
+
* a user message (matching legacy storage conventions).
|
|
129
|
+
*/
|
|
130
|
+
export declare function agentMessageToMessageWithMetadata(message: AgentMessage): MessageWithMetadata;
|
|
131
|
+
/**
|
|
132
|
+
* Bulk-adapter for the reverse direction.
|
|
133
|
+
*/
|
|
134
|
+
export declare function agentMessagesToMessagesWithMetadata(messages: readonly AgentMessage[]): MessageWithMetadata[];
|
|
135
|
+
/**
|
|
136
|
+
* Lossy but adequate: `AgentMessage[]` → `LlmsProviders.Message[]`.
|
|
137
|
+
* Used to feed the legacy `ApiHandler.createMessage()` in
|
|
138
|
+
* {@link apiHandlerToAgentModel}. Drops fields that the handler
|
|
139
|
+
* does not consume (id, ts, metrics, modelInfo).
|
|
140
|
+
*/
|
|
141
|
+
export declare function agentMessagesToMessages(messages: readonly AgentMessage[]): Message[];
|
|
142
|
+
/**
|
|
143
|
+
* Map runtime `AgentToolDefinition[]` to legacy
|
|
144
|
+
* `LlmsProviders.ToolDefinition[]`. Structurally identical today —
|
|
145
|
+
* but typing them separately keeps the adapter explicit.
|
|
146
|
+
*/
|
|
147
|
+
export declare function agentToolDefinitionsToToolDefinitions(tools: AgentModelRequest["tools"]): ToolDefinition[];
|
|
148
|
+
//# sourceMappingURL=agent-config-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-config-adapter.d.ts","sourceRoot":"","sources":["../../src/runtime/agent-config-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EACX,UAAU,EACV,cAAc,EACd,cAAc,EACd,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EACX,YAAY,EAEZ,UAAU,EACV,eAAe,EACf,iBAAiB,EAEjB,SAAS,EAMT,OAAO,EACP,mBAAmB,EAInB,IAAI,EAIJ,MAAM,kBAAkB,CAAC;AAM1B;;;;;;GAMG;AACH,MAAM,WAAW,2BAA2B;IAC3C,iFAAiF;IACjF,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB;;;;;OAKG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,WAAW,GAAG,SAAS,CAAC;IACxD;;;;;OAKG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,CAC1B,QAAQ,EAAE,OAAO,EAAE,KACf,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;CACpC;AAED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AKG;AACH,wBAAgB,uBAAuB,CACtC,QAAQ,EAAE,SAAS,YAAY,EAAE,GAC/B,OAAO,EAAE,CA6BX;AAED;;;;GAIG;AACH,wBAAgB,qCAAqC,CACpD,KAAK,EAAE,iBAAiB,CAAC,OAAO,CAAC,GAC/B,cAAc,EAAE,CAMlB"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build an `AgentRuntimeConfig` from an `AgentConfig` plus session-owned
|
|
3
|
+
* supporting objects (model handler, tools, hooks, plugins, telemetry).
|
|
4
|
+
*
|
|
5
|
+
* @see PLAN.md §3.1 — new file introduced alongside the core runtime port.
|
|
6
|
+
* @see PLAN.md §3.2.1 — field-by-field mapping.
|
|
7
|
+
*
|
|
8
|
+
* Implemented in Step 8c. The function is intentionally **pure** — it
|
|
9
|
+
* does not create handlers or tools itself; it receives them already
|
|
10
|
+
* adapted (via `agent-config-adapter.ts`) from the caller
|
|
11
|
+
* (`SessionRuntime`) and wires them into an `AgentRuntimeConfig`.
|
|
12
|
+
*
|
|
13
|
+
* Fields that do **not** round-trip into `AgentRuntimeConfig`
|
|
14
|
+
* (e.g. `execution.maxConsecutiveMistakes`,
|
|
15
|
+
* `execution.loopDetection`, `hookPolicies`) are
|
|
16
|
+
* consumed by `SessionRuntime` / `MistakeTracker` /
|
|
17
|
+
* `LoopDetectionTracker` — not passed through here. See §3.2.1's
|
|
18
|
+
* "Fields with no corresponding AgentRuntimeConfig slot" note.
|
|
19
|
+
*/
|
|
20
|
+
import type { AgentConfig, AgentMessage, AgentModel, AgentRuntimeConfig, AgentRuntimePlugin, AgentTelemetry, AgentTool, BasicLogger } from "@clinebot/shared";
|
|
21
|
+
import type { HookBridge } from "../hooks/hook-bridge";
|
|
22
|
+
/**
|
|
23
|
+
* Inputs required to assemble an `AgentRuntimeConfig`. Distinct from
|
|
24
|
+
* `AgentConfig` because some of these (the model adapter, the hook
|
|
25
|
+
* bridge's runtime-hooks bag, a resolved plugin list) can only be
|
|
26
|
+
* produced inside `SessionRuntime`.
|
|
27
|
+
*/
|
|
28
|
+
export interface CreateAgentRuntimeConfigInput {
|
|
29
|
+
readonly agentConfig: AgentConfig;
|
|
30
|
+
/**
|
|
31
|
+
* Core/hub runtime session identifier used for host lifecycle operations,
|
|
32
|
+
* event routing, persistence, and approval delivery.
|
|
33
|
+
*/
|
|
34
|
+
readonly sessionId?: string;
|
|
35
|
+
readonly agentId: string;
|
|
36
|
+
/**
|
|
37
|
+
* Agent conversation/transcript identifier used by tools, hooks, telemetry,
|
|
38
|
+
* and model history correlation.
|
|
39
|
+
*/
|
|
40
|
+
readonly conversationId?: string;
|
|
41
|
+
readonly parentAgentId?: string;
|
|
42
|
+
/** The role label for teammates (`AgentConfig.role` in sub-agent configs). */
|
|
43
|
+
readonly agentRole?: string;
|
|
44
|
+
/** Pre-built model adapter (produced by `apiHandlerToAgentModel`). */
|
|
45
|
+
readonly model: AgentModel;
|
|
46
|
+
readonly logger?: BasicLogger;
|
|
47
|
+
readonly telemetry?: AgentTelemetry;
|
|
48
|
+
/** Pre-built tool array (builtins + plugin-contributed + session extras). */
|
|
49
|
+
readonly tools?: readonly AgentTool<unknown, unknown>[];
|
|
50
|
+
/** Pre-resolved plugin list from the plugin loader. */
|
|
51
|
+
readonly plugins?: readonly AgentRuntimePlugin[];
|
|
52
|
+
/**
|
|
53
|
+
* Optional hook bridge. When provided, `AgentRuntimeConfig.hooks`
|
|
54
|
+
* is populated from `hookBridge.toRuntimeHooks()`. Omit for
|
|
55
|
+
* runtimes that do not need hook dispatch (e.g. unit tests).
|
|
56
|
+
*/
|
|
57
|
+
readonly hookBridge?: HookBridge;
|
|
58
|
+
/** Seed messages (usually `session.conversation.getMessages()`). */
|
|
59
|
+
readonly initialMessages?: readonly AgentMessage[];
|
|
60
|
+
/**
|
|
61
|
+
* Override for `AgentRuntimeConfig.systemPrompt` — useful when
|
|
62
|
+
* the caller has composed additional guidance (e.g. via
|
|
63
|
+
* `LocalRuntimeHost.composeSystemPrompt`). Defaults to
|
|
64
|
+
* `agentConfig.systemPrompt`.
|
|
65
|
+
*/
|
|
66
|
+
readonly systemPrompt?: string;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Produce an `AgentRuntimeConfig` per PLAN.md §3.2.1 mapping.
|
|
70
|
+
*/
|
|
71
|
+
export declare function createAgentRuntimeConfig(input: CreateAgentRuntimeConfigInput): AgentRuntimeConfig;
|
|
72
|
+
/**
|
|
73
|
+
* Collect the provider-/reasoning-related fields from `AgentConfig`
|
|
74
|
+
* into `AgentRuntimeConfig.modelOptions`. Kept undefined when every
|
|
75
|
+
* field is undefined so the runtime does not receive an empty object.
|
|
76
|
+
*/
|
|
77
|
+
export declare function buildModelOptions(config: AgentConfig): Record<string, unknown> | undefined;
|
|
78
|
+
/**
|
|
79
|
+
* Compose `messageModelInfo` from the provider-related fields per
|
|
80
|
+
* §3.2.1: `{ id: modelId, provider: providerId, family:
|
|
81
|
+
* providerConfig?.family }`.
|
|
82
|
+
*/
|
|
83
|
+
export declare function buildMessageModelInfo(config: AgentConfig): AgentMessage["modelInfo"];
|
|
84
|
+
/**
|
|
85
|
+
* `"parallel"` when `maxParallelToolCalls ≥ 2`, `"sequential"` when
|
|
86
|
+
* `1`, `undefined` when the caller did not specify.
|
|
87
|
+
*/
|
|
88
|
+
export declare function resolveToolExecution(maxParallelToolCalls: number | undefined): "sequential" | "parallel" | undefined;
|
|
89
|
+
/**
|
|
90
|
+
* Adapt the full `ITelemetryService` to the minimal `AgentTelemetry`
|
|
91
|
+
* shape. The runtime only calls `capture(event, properties)`; the
|
|
92
|
+
* remaining methods are host concerns and stay on the
|
|
93
|
+
* `ITelemetryService` instance owned by `SessionRuntime`.
|
|
94
|
+
*/
|
|
95
|
+
export declare function mapTelemetry(telemetry: AgentConfig["telemetry"]): AgentTelemetry | undefined;
|
|
96
|
+
//# sourceMappingURL=agent-runtime-config-builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{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M,CAAC;CAC/B;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CACvC,KAAK,EAAE,6BAA6B,GAClC,kBAAkB,CA8BpB;AAMD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAChC,MAAM,EAAE,WAAW,GACjB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAkBrC;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CACpC,MAAM,EAAE,WAAW,GACjB,YAAY,CAAC,WAAW,CAAC,CAQ3B;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CACnC,oBAAoB,EAAE,MAAM,GAAG,SAAS,GACtC,YAAY,GAAG,UAAU,GAAG,SAAS,CAKvC;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAC3B,SAAS,EAAE,WAAW,CAAC,WAAW,CAAC,GACjC,cAAc,GAAG,SAAS,CAmB5B"}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import type { SessionHistoryRecord, SessionRecord } from "../types/sessions";
|
|
2
2
|
import type { RuntimeHost } from "./runtime-host";
|
|
3
|
+
export interface SessionHistoryListOptions {
|
|
4
|
+
limit?: number;
|
|
5
|
+
includeManifestFallback?: boolean;
|
|
6
|
+
hydrate?: boolean;
|
|
7
|
+
}
|
|
3
8
|
export declare function hydrateSessionHistory(host: Pick<RuntimeHost, "readMessages">, rows: SessionRecord[]): Promise<SessionHistoryRecord[]>;
|
|
9
|
+
export declare function listSessionHistory(host: Pick<RuntimeHost, "list" | "readMessages">, options?: SessionHistoryListOptions): Promise<SessionHistoryRecord[]>;
|
|
4
10
|
//# sourceMappingURL=history.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../src/runtime/history.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../src/runtime/history.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAEX,oBAAoB,EACpB,aAAa,EACb,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,MAAM,WAAW,yBAAyB;IACzC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,OAAO,CAAC,EAAE,OAAO,CAAC;CAClB;AAySD,wBAAsB,qBAAqB,CAC1C,IAAI,EAAE,IAAI,CAAC,WAAW,EAAE,cAAc,CAAC,EACvC,IAAI,EAAE,aAAa,EAAE,GACnB,OAAO,CAAC,oBAAoB,EAAE,CAAC,CA0BjC;AAED,wBAAsB,kBAAkB,CACvC,IAAI,EAAE,IAAI,CAAC,WAAW,EAAE,MAAM,GAAG,cAAc,CAAC,EAChD,OAAO,GAAE,yBAA8B,GACrC,OAAO,CAAC,oBAAoB,EAAE,CAAC,CAwBjC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../../src/runtime/host.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../../src/runtime/host.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAQrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAIhE,OAAO,KAAK,EAAE,WAAW,EAAmB,MAAM,gBAAgB,CAAC;AAkBnE,MAAM,MAAM,cAAc,GAAG,kBAAkB,GAAG,kBAAkB,CAAC;AAsErE,wBAAsB,qBAAqB,CAC1C,OAAO,EAAE,gBAAgB,GACvB,OAAO,CAAC,cAAc,CAAC,CAiBzB;AAED,wBAAsB,iBAAiB,CACtC,OAAO,EAAE,gBAAgB,GACvB,OAAO,CAAC,WAAW,CAAC,CAiGtB"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Repeated tool-call loop detection.
|
|
3
|
+
*
|
|
4
|
+
* @see PLAN.md §3.1 — helpers moved from `packages/agents/src/context/loop-detection.ts`.
|
|
5
|
+
* @see PLAN.md §3.2.3 — public surface of `LoopDetectionTracker`.
|
|
6
|
+
*
|
|
7
|
+
* The pure helpers (`createLoopDetectionState`, `resetLoopDetectionState`,
|
|
8
|
+
* `toolCallSignature`, `checkRepeatedToolCall`) are ported verbatim. The
|
|
9
|
+
* `LoopDetectionTracker` class is a thin wrapper that owns a
|
|
10
|
+
* `LoopDetectionState` and exposes the `inspect()` / `reset()` surface that
|
|
11
|
+
* `SessionRuntime` installs as a `beforeTool` hook per §3.2.3.
|
|
12
|
+
*/
|
|
13
|
+
import type { LoopDetectionConfig } from "@clinebot/shared";
|
|
14
|
+
export interface LoopDetectionState {
|
|
15
|
+
lastToolName: string;
|
|
16
|
+
lastToolSignature: string;
|
|
17
|
+
consecutiveIdenticalCount: number;
|
|
18
|
+
}
|
|
19
|
+
export declare function createLoopDetectionState(): LoopDetectionState;
|
|
20
|
+
export declare function resetLoopDetectionState(state: LoopDetectionState): void;
|
|
21
|
+
export declare function toolCallSignature(input: unknown): string;
|
|
22
|
+
export interface LoopCheckResult {
|
|
23
|
+
softWarning: boolean;
|
|
24
|
+
hardEscalation: boolean;
|
|
25
|
+
}
|
|
26
|
+
export declare function checkRepeatedToolCall(state: LoopDetectionState, toolName: string, signature: string, config: LoopDetectionConfig): LoopCheckResult;
|
|
27
|
+
/**
|
|
28
|
+
* Verdict returned by {@link LoopDetectionTracker.inspect}.
|
|
29
|
+
*
|
|
30
|
+
* - `"ok"` — no repeated call detected.
|
|
31
|
+
* - `"soft"` — soft-warning threshold reached; SessionRuntime may surface a
|
|
32
|
+
* recovery notice but should not block the call.
|
|
33
|
+
* - `"hard"` — hard-escalation threshold reached; SessionRuntime should
|
|
34
|
+
* stop the run with the provided `message`.
|
|
35
|
+
*/
|
|
36
|
+
export interface LoopDetectionVerdict {
|
|
37
|
+
kind: "ok" | "soft" | "hard";
|
|
38
|
+
message?: string;
|
|
39
|
+
}
|
|
40
|
+
/** Minimal call shape the tracker needs; matches `AgentToolCallPart` subset. */
|
|
41
|
+
export interface LoopDetectionCall {
|
|
42
|
+
name: string;
|
|
43
|
+
input: unknown;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Per-session repeated-tool-call detector.
|
|
47
|
+
*
|
|
48
|
+
* `SessionRuntime` owns the instance and installs a `beforeTool` hook
|
|
49
|
+
* (see `AgentRuntimeHooks.beforeTool`) that calls `inspect()` to decide
|
|
50
|
+
* whether to return `{ skip, stop, reason }`.
|
|
51
|
+
*/
|
|
52
|
+
export declare class LoopDetectionTracker {
|
|
53
|
+
private readonly config;
|
|
54
|
+
private readonly state;
|
|
55
|
+
constructor(config?: Partial<LoopDetectionConfig>);
|
|
56
|
+
inspect(call: LoopDetectionCall): LoopDetectionVerdict;
|
|
57
|
+
reset(): void;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=loop-detection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loop-detection.d.ts","sourceRoot":"","sources":["../../src/runtime/loop-detection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAM5D,MAAM,WAAW,kBAAkB;IAClC,YAAY,EAAE,MAAM,CAAC;IACrB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,yBAAyB,EAAE,MAAM,CAAC;CAClC;AAED,wBAAgB,wBAAwB,IAAI,kBAAkB,CAM7D;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,kBAAkB,GAAG,IAAI,CAIvE;AAYD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CASxD;AAED,MAAM,WAAW,eAAe;IAC/B,WAAW,EAAE,OAAO,CAAC;IACrB,cAAc,EAAE,OAAO,CAAC;CACxB;AAED,wBAAgB,qBAAqB,CACpC,KAAK,EAAE,kBAAkB,EACzB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,mBAAmB,GACzB,eAAe,CAgBjB;AAMD;;;;;;;;GAQG;AACH,MAAM,WAAW,oBAAoB;IACpC,IAAI,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,CAAC;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,gFAAgF;AAChF,MAAM,WAAW,iBAAiB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,OAAO,CAAC;CACf;AAOD;;;;;;GAMG;AACH,qBAAa,oBAAoB;IAChC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAsB;IAC7C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAkD;gBAE5D,MAAM,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC;IAOjD,OAAO,CAAC,IAAI,EAAE,iBAAiB,GAAG,oBAAoB;IAuBtD,KAAK,IAAI,IAAI;CAGb"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-session consecutive-mistake tracker.
|
|
3
|
+
*
|
|
4
|
+
* @see PLAN.md §3.1 — wrapped around `recordMistake` moved from
|
|
5
|
+
* `packages/agents/src/api/error-handling.ts` lines 147–311.
|
|
6
|
+
* @see PLAN.md §3.2.3 — public surface of `MistakeTracker`.
|
|
7
|
+
*
|
|
8
|
+
* The pure procedural `recordMistake(input, deps)` becomes `record(input)`
|
|
9
|
+
* on the class; `consecutiveMistakes` is internal state. Other deps flow
|
|
10
|
+
* through the constructor instead.
|
|
11
|
+
*
|
|
12
|
+
* NOTE: the §3.2.3 constructor shape omits some fields (agentId,
|
|
13
|
+
* conversationId/runId getters, appendRecoveryNotice). They are retained
|
|
14
|
+
* here for log + notice parity per PLAN.md §3.4.3/§3.4.5. Step 8
|
|
15
|
+
* (`impl-runtime-porter`) may refactor once SessionRuntime is wired up.
|
|
16
|
+
*/
|
|
17
|
+
import type { AgentEvent, BasicLogMetadata, ConsecutiveMistakeLimitContext, ConsecutiveMistakeLimitDecision } from "@clinebot/shared";
|
|
18
|
+
/**
|
|
19
|
+
* Legacy-agents-style leveled log function. The sdk-re `BasicLogger`
|
|
20
|
+
* does not carry a level argument (§shared/logging/logger.ts); callers
|
|
21
|
+
* are expected to bridge via `metadata.severity` or dispatch to
|
|
22
|
+
* `debug`/`log`/`error`. `MistakeTracker` accepts a leveled callable
|
|
23
|
+
* here so Step 8 can plug in whichever bridging shape `SessionRuntime`
|
|
24
|
+
* ends up using.
|
|
25
|
+
*/
|
|
26
|
+
export type LeveledLog = (level: "debug" | "info" | "warn" | "error", message: string, metadata?: BasicLogMetadata) => void;
|
|
27
|
+
export type MistakeReason = "api_error" | "invalid_tool_call" | "tool_execution_failed";
|
|
28
|
+
export interface RecordMistakeInput {
|
|
29
|
+
iteration: number;
|
|
30
|
+
reason: MistakeReason;
|
|
31
|
+
details?: string;
|
|
32
|
+
/** When true, jump straight to maxConsecutiveMistakes instead of incrementing by 1. */
|
|
33
|
+
forceAtLimit?: boolean;
|
|
34
|
+
}
|
|
35
|
+
export type MistakeOutcome = {
|
|
36
|
+
action: "continue";
|
|
37
|
+
guidance?: string;
|
|
38
|
+
} | {
|
|
39
|
+
action: "stop";
|
|
40
|
+
message: string;
|
|
41
|
+
reason?: string;
|
|
42
|
+
};
|
|
43
|
+
export interface MistakeTrackerOptions {
|
|
44
|
+
readonly maxConsecutiveMistakes: number;
|
|
45
|
+
readonly onLimitReached?: (ctx: ConsecutiveMistakeLimitContext) => Promise<ConsecutiveMistakeLimitDecision> | ConsecutiveMistakeLimitDecision;
|
|
46
|
+
readonly emit: (event: AgentEvent) => void;
|
|
47
|
+
readonly log: LeveledLog;
|
|
48
|
+
readonly agentId: string;
|
|
49
|
+
readonly getConversationId: () => string;
|
|
50
|
+
readonly getActiveRunId: () => string;
|
|
51
|
+
readonly appendRecoveryNotice: (message: string, reason: MistakeReason) => void;
|
|
52
|
+
}
|
|
53
|
+
export declare class MistakeTracker {
|
|
54
|
+
private consecutiveMistakes;
|
|
55
|
+
private readonly options;
|
|
56
|
+
constructor(options: MistakeTrackerOptions);
|
|
57
|
+
record(input: RecordMistakeInput): Promise<MistakeOutcome>;
|
|
58
|
+
reset(): void;
|
|
59
|
+
get value(): number;
|
|
60
|
+
}
|
|
61
|
+
export declare function buildMistakeLimitStopMessage(input: {
|
|
62
|
+
iteration: number;
|
|
63
|
+
consecutiveMistakes: number;
|
|
64
|
+
maxConsecutiveMistakes: number;
|
|
65
|
+
reason: "api_error" | "invalid_tool_call" | "completion_without_submit" | "tool_execution_failed";
|
|
66
|
+
details?: string;
|
|
67
|
+
stopReason?: string;
|
|
68
|
+
}): string;
|
|
69
|
+
//# sourceMappingURL=mistake-tracker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mistake-tracker.d.ts","sourceRoot":"","sources":["../../src/runtime/mistake-tracker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EACX,UAAU,EACV,gBAAgB,EAChB,8BAA8B,EAC9B,+BAA+B,EAC/B,MAAM,kBAAkB,CAAC;AAE1B;;;;;;;GAOG;AACH,MAAM,MAAM,UAAU,GAAG,CACxB,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,EAC1C,OAAO,EAAE,MAAM,EACf,QAAQ,CAAC,EAAE,gBAAgB,KACvB,IAAI,CAAC;AAEV,MAAM,MAAM,aAAa,GACtB,WAAW,GACX,mBAAmB,GACnB,uBAAuB,CAAC;AAE3B,MAAM,WAAW,kBAAkB;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,aAAa,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,uFA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,EACH,WAAW,GACX,mBAAmB,GACnB,2BAA2B,GAC3B,uBAAuB,CAAC;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,MAAM,CAgBT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-builder.d.ts","sourceRoot":"","sources":["../../src/runtime/runtime-builder.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"runtime-builder.d.ts","sourceRoot":"","sources":["../../src/runtime/runtime-builder.ts"],"names":[],"mappings":"AA6CA,OAAO,KAAK,EACX,cAAc,EACd,mBAAmB,EACnB,YAAY,IAAI,kBAAkB,EAClC,MAAM,mBAAmB,CAAC;AAwD3B,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AA+YD,qBAAa,qBAAsB,YAAW,cAAc;IAC3D,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAQ/B;IAEE,KAAK,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAwSpE"}
|