botinabox 2.5.0 → 2.5.2
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/LICENSE +21 -21
- package/README.md +190 -190
- package/bin/botinabox.mjs +2 -2
- package/dist/channels/discord/adapter.d.ts +32 -0
- package/dist/channels/discord/adapter.js +70 -0
- package/dist/channels/discord/inbound.d.ts +25 -0
- package/dist/channels/discord/inbound.js +24 -0
- package/dist/channels/discord/models.d.ts +8 -0
- package/dist/channels/discord/models.js +5 -0
- package/dist/channels/discord/outbound.d.ts +14 -0
- package/dist/channels/discord/outbound.js +38 -0
- package/dist/channels/slack/adapter.d.ts +33 -0
- package/dist/channels/slack/adapter.js +74 -0
- package/dist/channels/slack/inbound.d.ts +59 -0
- package/dist/channels/slack/inbound.js +96 -0
- package/dist/channels/slack/models.d.ts +9 -0
- package/dist/channels/slack/models.js +5 -0
- package/dist/channels/slack/outbound.d.ts +12 -0
- package/dist/channels/slack/outbound.js +18 -0
- package/dist/channels/slack/transcribe.d.ts +41 -0
- package/dist/channels/slack/transcribe.js +106 -0
- package/dist/channels/webhook/adapter.d.ts +23 -0
- package/dist/channels/webhook/adapter.js +86 -0
- package/dist/channels/webhook/hmac.d.ts +13 -0
- package/dist/channels/webhook/hmac.js +26 -0
- package/dist/channels/webhook/models.d.ts +9 -0
- package/dist/channels/webhook/models.js +5 -0
- package/dist/channels/webhook/server.d.ts +20 -0
- package/dist/channels/webhook/server.js +91 -0
- package/dist/chat-pipeline-BWrtVqEP.d.ts +652 -0
- package/dist/chat-pipeline-C-XlLGNl.d.ts +648 -0
- package/dist/chat-pipeline-CR1KF6eX.d.ts +652 -0
- package/dist/chat-pipeline-DisuC8SB.d.ts +643 -0
- package/dist/chunk-2LGXQPEA.js +41 -0
- package/dist/chunk-3X3YKI4T.js +357 -0
- package/dist/chunk-D47AIFOD.js +351 -0
- package/dist/chunk-DSNJKNEW.js +328 -0
- package/dist/chunk-GS2JFL6I.js +144 -0
- package/dist/chunk-J6S6QMUY.js +144 -0
- package/dist/chunk-QLA6YOFN.js +22 -0
- package/dist/chunk-UACT2WXX.js +381 -0
- package/dist/cli/templates/config.yml.d.ts +7 -0
- package/dist/cli/templates/config.yml.js +61 -0
- package/dist/cli/templates/env.d.ts +1 -0
- package/dist/cli/templates/env.js +30 -0
- package/dist/cli/templates/index.ts.d.ts +2 -0
- package/dist/cli/templates/index.ts.js +30 -0
- package/dist/cli/templates/package.json.d.ts +5 -0
- package/dist/cli/templates/package.json.js +28 -0
- package/dist/cli.js +0 -0
- package/dist/connector-DDahQw-2.d.ts +63 -0
- package/dist/connectors/google/calendar-connector.d.ts +40 -0
- package/dist/connectors/google/calendar-connector.js +243 -0
- package/dist/connectors/google/gmail-connector.d.ts +42 -0
- package/dist/connectors/google/gmail-connector.js +345 -0
- package/dist/connectors/google/index.d.ts +67 -1
- package/dist/connectors/google/index.js +240 -0
- package/dist/connectors/google/oauth.d.ts +48 -0
- package/dist/connectors/google/oauth.js +112 -0
- package/dist/connectors/google/types.d.ts +78 -0
- package/dist/connectors/google/types.js +2 -0
- package/dist/core/chat/auto-discovery.d.ts +16 -0
- package/dist/core/chat/auto-discovery.js +54 -0
- package/dist/core/chat/channel-registry.d.ts +45 -0
- package/dist/core/chat/channel-registry.js +96 -0
- package/dist/core/chat/chat-pipeline.d.ts +113 -0
- package/dist/core/chat/chat-pipeline.js +395 -0
- package/dist/core/chat/chat-responder.d.ts +90 -0
- package/dist/core/chat/chat-responder.js +185 -0
- package/dist/core/chat/formatter.d.ts +11 -0
- package/dist/core/chat/formatter.js +60 -0
- package/dist/core/chat/index.d.ts +24 -0
- package/dist/core/chat/index.js +18 -0
- package/dist/core/chat/message-interpreter.d.ts +91 -0
- package/dist/core/chat/message-interpreter.js +166 -0
- package/dist/core/chat/message-store.d.ts +66 -0
- package/dist/core/chat/message-store.js +131 -0
- package/dist/core/chat/notification-queue.d.ts +34 -0
- package/dist/core/chat/notification-queue.js +111 -0
- package/dist/core/chat/pipeline.d.ts +38 -0
- package/dist/core/chat/pipeline.js +89 -0
- package/dist/core/chat/policies.d.ts +16 -0
- package/dist/core/chat/policies.js +25 -0
- package/dist/core/chat/routing.d.ts +17 -0
- package/dist/core/chat/routing.js +36 -0
- package/dist/core/chat/session-key.d.ts +30 -0
- package/dist/core/chat/session-key.js +65 -0
- package/dist/core/chat/session-manager.d.ts +17 -0
- package/dist/core/chat/session-manager.js +23 -0
- package/dist/core/chat/text-chunker.d.ts +9 -0
- package/dist/core/chat/text-chunker.js +48 -0
- package/dist/core/chat/triage-router.d.ts +75 -0
- package/dist/core/chat/triage-router.js +142 -0
- package/dist/core/chat/types.d.ts +5 -0
- package/dist/core/chat/types.js +5 -0
- package/dist/core/config/defaults.d.ts +2 -0
- package/dist/core/config/defaults.js +38 -0
- package/dist/core/config/index.d.ts +6 -0
- package/dist/core/config/index.js +4 -0
- package/dist/core/config/interpolate.d.ts +5 -0
- package/dist/core/config/interpolate.js +27 -0
- package/dist/core/config/loader.d.ts +24 -0
- package/dist/core/config/loader.js +59 -0
- package/dist/core/config/schema.d.ts +5 -0
- package/dist/core/config/schema.js +119 -0
- package/dist/core/data/core-entity-contexts.d.ts +14 -0
- package/dist/core/data/core-entity-contexts.js +197 -0
- package/dist/core/data/core-migrations.d.ts +5 -0
- package/dist/core/data/core-migrations.js +45 -0
- package/dist/core/data/core-schema.d.ts +6 -0
- package/dist/core/data/core-schema.js +454 -0
- package/dist/core/data/data-store.d.ts +67 -0
- package/dist/core/data/data-store.js +218 -0
- package/dist/core/data/domain-entity-contexts.d.ts +29 -0
- package/dist/core/data/domain-entity-contexts.js +321 -0
- package/dist/core/data/domain-schema.d.ts +36 -0
- package/dist/core/data/domain-schema.js +323 -0
- package/dist/core/data/index.d.ts +7 -0
- package/dist/core/data/index.js +7 -0
- package/dist/core/data/types.d.ts +111 -0
- package/dist/core/data/types.js +1 -0
- package/dist/core/hooks/hook-bus.d.ts +18 -0
- package/dist/core/hooks/hook-bus.js +120 -0
- package/dist/core/hooks/index.d.ts +2 -0
- package/dist/core/hooks/index.js +1 -0
- package/dist/core/hooks/types.d.ts +19 -0
- package/dist/core/hooks/types.js +1 -0
- package/dist/core/index.d.ts +4 -0
- package/dist/core/index.js +4 -0
- package/dist/core/llm/auto-discovery.d.ts +11 -0
- package/dist/core/llm/auto-discovery.js +49 -0
- package/dist/core/llm/cost-tracker.d.ts +6 -0
- package/dist/core/llm/cost-tracker.js +38 -0
- package/dist/core/llm/index.d.ts +4 -0
- package/dist/core/llm/index.js +3 -0
- package/dist/core/llm/model-router.d.ts +25 -0
- package/dist/core/llm/model-router.js +49 -0
- package/dist/core/llm/provider-registry.d.ts +9 -0
- package/dist/core/llm/provider-registry.js +25 -0
- package/dist/core/llm/types.d.ts +2 -0
- package/dist/core/llm/types.js +2 -0
- package/dist/core/orchestrator/adapters/api-adapter.d.ts +34 -0
- package/dist/core/orchestrator/adapters/api-adapter.js +88 -0
- package/dist/core/orchestrator/adapters/cli-adapter.d.ts +22 -0
- package/dist/core/orchestrator/adapters/cli-adapter.js +69 -0
- package/dist/core/orchestrator/adapters/deterministic-adapter.d.ts +35 -0
- package/dist/core/orchestrator/adapters/deterministic-adapter.js +75 -0
- package/dist/core/orchestrator/adapters/env-whitelist.d.ts +4 -0
- package/dist/core/orchestrator/adapters/env-whitelist.js +27 -0
- package/dist/core/orchestrator/adapters/output-extractor.d.ts +11 -0
- package/dist/core/orchestrator/adapters/output-extractor.js +59 -0
- package/dist/core/orchestrator/adapters/process-manager.d.ts +15 -0
- package/dist/core/orchestrator/adapters/process-manager.js +26 -0
- package/dist/core/orchestrator/adapters/tool-loop.d.ts +22 -0
- package/dist/core/orchestrator/adapters/tool-loop.js +66 -0
- package/dist/core/orchestrator/agent-registry.d.ts +31 -0
- package/dist/core/orchestrator/agent-registry.js +135 -0
- package/dist/core/orchestrator/budget-controller.d.ts +19 -0
- package/dist/core/orchestrator/budget-controller.js +73 -0
- package/dist/core/orchestrator/chain-guard.d.ts +14 -0
- package/dist/core/orchestrator/chain-guard.js +23 -0
- package/dist/core/orchestrator/circuit-breaker.d.ts +65 -0
- package/dist/core/orchestrator/circuit-breaker.js +159 -0
- package/dist/core/orchestrator/claude-stream-parser.d.ts +31 -0
- package/dist/core/orchestrator/claude-stream-parser.js +99 -0
- package/dist/core/orchestrator/config-revisions.d.ts +6 -0
- package/dist/core/orchestrator/config-revisions.js +17 -0
- package/dist/core/orchestrator/dependency-resolver.d.ts +20 -0
- package/dist/core/orchestrator/dependency-resolver.js +78 -0
- package/dist/core/orchestrator/governance-gate.d.ts +110 -0
- package/dist/core/orchestrator/governance-gate.js +170 -0
- package/dist/core/orchestrator/learning-pipeline.d.ts +109 -0
- package/dist/core/orchestrator/learning-pipeline.js +249 -0
- package/dist/core/orchestrator/loop-detector.d.ts +51 -0
- package/dist/core/orchestrator/loop-detector.js +133 -0
- package/dist/core/orchestrator/ndjson-logger.d.ts +6 -0
- package/dist/core/orchestrator/ndjson-logger.js +18 -0
- package/dist/core/orchestrator/permission-relay.d.ts +72 -0
- package/dist/core/orchestrator/permission-relay.js +164 -0
- package/dist/core/orchestrator/run-manager.d.ts +31 -0
- package/dist/core/orchestrator/run-manager.js +178 -0
- package/dist/core/orchestrator/scheduler.d.ts +70 -0
- package/dist/core/orchestrator/scheduler.js +198 -0
- package/dist/core/orchestrator/secret-store.d.ts +57 -0
- package/dist/core/orchestrator/secret-store.js +171 -0
- package/dist/core/orchestrator/session-manager.d.ts +13 -0
- package/dist/core/orchestrator/session-manager.js +66 -0
- package/dist/core/orchestrator/task-queue.d.ts +34 -0
- package/dist/core/orchestrator/task-queue.js +83 -0
- package/dist/core/orchestrator/template-interpolate.d.ts +5 -0
- package/dist/core/orchestrator/template-interpolate.js +18 -0
- package/dist/core/orchestrator/user-registry.d.ts +47 -0
- package/dist/core/orchestrator/user-registry.js +76 -0
- package/dist/core/orchestrator/wakeup-queue.d.ts +9 -0
- package/dist/core/orchestrator/wakeup-queue.js +45 -0
- package/dist/core/orchestrator/workflow-engine.d.ts +47 -0
- package/dist/core/orchestrator/workflow-engine.js +204 -0
- package/dist/core/security/audit.d.ts +20 -0
- package/dist/core/security/audit.js +33 -0
- package/dist/core/security/column-validator.d.ts +20 -0
- package/dist/core/security/column-validator.js +37 -0
- package/dist/core/security/index.d.ts +5 -0
- package/dist/core/security/index.js +5 -0
- package/dist/core/security/process-env.d.ts +13 -0
- package/dist/core/security/process-env.js +49 -0
- package/dist/core/security/sanitizer.d.ts +11 -0
- package/dist/core/security/sanitizer.js +39 -0
- package/dist/core/security/types.d.ts +11 -0
- package/dist/core/security/types.js +1 -0
- package/dist/core/update/auto-update.d.ts +21 -0
- package/dist/core/update/auto-update.js +102 -0
- package/dist/core/update/backup-manager.d.ts +7 -0
- package/dist/core/update/backup-manager.js +24 -0
- package/dist/core/update/index.d.ts +8 -0
- package/dist/core/update/index.js +6 -0
- package/dist/core/update/migration-hooks.d.ts +11 -0
- package/dist/core/update/migration-hooks.js +10 -0
- package/dist/core/update/types.d.ts +11 -0
- package/dist/core/update/types.js +1 -0
- package/dist/core/update/update-checker.d.ts +11 -0
- package/dist/core/update/update-checker.js +63 -0
- package/dist/core/update/update-manager.d.ts +25 -0
- package/dist/core/update/update-manager.js +101 -0
- package/dist/core/update/version-utils.d.ts +6 -0
- package/dist/core/update/version-utils.js +34 -0
- package/dist/gmail-connector-2FVYTQJH.js +6 -0
- package/dist/gmail-connector-MNUBRNFM.js +6 -0
- package/dist/gmail-connector-PS2VLGNE.js +6 -0
- package/dist/gmail-connector-ULSMN6X2.js +6 -0
- package/dist/gmail-connector-URRFX6A3.js +6 -0
- package/dist/inbound-AFBUPSPG.js +10 -0
- package/dist/inbound-AFOHYNUY.js +6 -0
- package/dist/inbound-CGIXRXGC.js +8 -0
- package/dist/inbound-MCOLRH6U.js +10 -0
- package/dist/inbound-SNEMBLGA.js +6 -0
- package/dist/inbound-ZJHAYVMF.js +10 -0
- package/dist/index.d.ts +11 -1
- package/dist/index.js +27 -11
- package/dist/provider-qqJYv9nv.d.ts +75 -0
- package/dist/providers/anthropic/models.d.ts +2 -0
- package/dist/providers/anthropic/models.js +29 -0
- package/dist/providers/anthropic/provider.d.ts +13 -0
- package/dist/providers/anthropic/provider.js +119 -0
- package/dist/providers/anthropic/tool-converter.d.ts +10 -0
- package/dist/providers/anthropic/tool-converter.js +7 -0
- package/dist/providers/ollama/provider.d.ts +17 -0
- package/dist/providers/ollama/provider.js +185 -0
- package/dist/providers/openai/models.d.ts +2 -0
- package/dist/providers/openai/models.js +29 -0
- package/dist/providers/openai/provider.d.ts +13 -0
- package/dist/providers/openai/provider.js +163 -0
- package/dist/providers/openai/tool-converter.d.ts +10 -0
- package/dist/providers/openai/tool-converter.js +10 -0
- package/dist/shared/constants.d.ts +50 -0
- package/dist/shared/constants.js +64 -0
- package/dist/shared/index.d.ts +14 -0
- package/dist/shared/index.js +14 -0
- package/dist/shared/types/agent.d.ts +36 -0
- package/dist/shared/types/agent.js +2 -0
- package/dist/shared/types/channel.d.ts +70 -0
- package/dist/shared/types/channel.js +2 -0
- package/dist/shared/types/config.d.ts +111 -0
- package/dist/shared/types/config.js +2 -0
- package/dist/shared/types/connector.d.ts +77 -0
- package/dist/shared/types/connector.js +2 -0
- package/dist/shared/types/execution.d.ts +29 -0
- package/dist/shared/types/execution.js +2 -0
- package/dist/shared/types/provider.d.ts +73 -0
- package/dist/shared/types/provider.js +2 -0
- package/dist/shared/types/task.d.ts +47 -0
- package/dist/shared/types/task.js +2 -0
- package/dist/shared/types/workflow.d.ts +39 -0
- package/dist/shared/types/workflow.js +2 -0
- package/dist/shared/utils.d.ts +6 -0
- package/dist/shared/utils.js +13 -0
- package/dist/update-check.d.ts +5 -0
- package/dist/update-check.js +56 -0
- package/package.json +100 -100
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface PackageUpdate {
|
|
2
|
+
name: string;
|
|
3
|
+
installedVersion: string;
|
|
4
|
+
latestVersion: string;
|
|
5
|
+
updateType: 'patch' | 'minor' | 'major';
|
|
6
|
+
}
|
|
7
|
+
export interface UpdateManifest {
|
|
8
|
+
checkedAt: string;
|
|
9
|
+
packages: PackageUpdate[];
|
|
10
|
+
hasUpdates: boolean;
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { UpdateManifest } from './types.js';
|
|
2
|
+
export declare class UpdateChecker {
|
|
3
|
+
private nodeModulesPath;
|
|
4
|
+
private opts?;
|
|
5
|
+
private readonly fetchFn;
|
|
6
|
+
constructor(nodeModulesPath: string, opts?: {
|
|
7
|
+
fetch?: typeof globalThis.fetch;
|
|
8
|
+
} | undefined);
|
|
9
|
+
getInstalledPackages(): string[];
|
|
10
|
+
check(packageNames?: string[]): Promise<UpdateManifest>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { readFileSync, readdirSync } from 'fs';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
import { classifyUpdate, compareVersions } from './version-utils.js';
|
|
4
|
+
export class UpdateChecker {
|
|
5
|
+
nodeModulesPath;
|
|
6
|
+
opts;
|
|
7
|
+
fetchFn;
|
|
8
|
+
constructor(nodeModulesPath, opts) {
|
|
9
|
+
this.nodeModulesPath = nodeModulesPath;
|
|
10
|
+
this.opts = opts;
|
|
11
|
+
this.fetchFn = opts?.fetch ?? globalThis.fetch;
|
|
12
|
+
}
|
|
13
|
+
getInstalledPackages() {
|
|
14
|
+
try {
|
|
15
|
+
const botinaboxPath = join(this.nodeModulesPath, '@botinabox');
|
|
16
|
+
const entries = readdirSync(botinaboxPath, { withFileTypes: true });
|
|
17
|
+
return entries
|
|
18
|
+
.filter((e) => e.isDirectory())
|
|
19
|
+
.map((e) => e.name);
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return [];
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
async check(packageNames) {
|
|
26
|
+
const installed = packageNames ?? this.getInstalledPackages();
|
|
27
|
+
const updates = [];
|
|
28
|
+
for (const pkg of installed) {
|
|
29
|
+
try {
|
|
30
|
+
const pkgJsonPath = join(this.nodeModulesPath, '@botinabox', pkg, 'package.json');
|
|
31
|
+
const pkgJson = JSON.parse(readFileSync(pkgJsonPath, 'utf-8'));
|
|
32
|
+
const installedVersion = pkgJson.version ?? '0.0.0';
|
|
33
|
+
const response = await this.fetchFn(`https://registry.npmjs.org/@botinabox/${pkg}`);
|
|
34
|
+
if (!response.ok)
|
|
35
|
+
continue;
|
|
36
|
+
const data = await response.json();
|
|
37
|
+
const latestVersion = data['dist-tags']?.['latest'];
|
|
38
|
+
if (!latestVersion)
|
|
39
|
+
continue;
|
|
40
|
+
if (compareVersions(latestVersion, installedVersion) > 0) {
|
|
41
|
+
const updateType = classifyUpdate(installedVersion, latestVersion);
|
|
42
|
+
if (updateType !== 'none') {
|
|
43
|
+
updates.push({
|
|
44
|
+
name: `@botinabox/${pkg}`,
|
|
45
|
+
installedVersion,
|
|
46
|
+
latestVersion,
|
|
47
|
+
updateType,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
// Gracefully skip on error
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
checkedAt: new Date().toISOString(),
|
|
59
|
+
packages: updates,
|
|
60
|
+
hasUpdates: updates.length > 0,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { DataStore } from '../data/data-store.js';
|
|
2
|
+
import type { HookBus } from '../hooks/hook-bus.js';
|
|
3
|
+
import type { PackageUpdate, UpdateManifest } from './types.js';
|
|
4
|
+
import { UpdateChecker } from './update-checker.js';
|
|
5
|
+
type UpdatePolicy = 'auto-all' | 'auto-compatible' | 'auto-patch' | 'notify' | 'manual';
|
|
6
|
+
export declare class UpdateManager {
|
|
7
|
+
private checker;
|
|
8
|
+
private db;
|
|
9
|
+
private hooks;
|
|
10
|
+
private opts?;
|
|
11
|
+
private backupManager;
|
|
12
|
+
constructor(checker: UpdateChecker, db: DataStore, hooks: HookBus, opts?: {
|
|
13
|
+
projectRoot?: string;
|
|
14
|
+
policy?: UpdatePolicy;
|
|
15
|
+
maintenanceWindow?: {
|
|
16
|
+
utcHourStart: number;
|
|
17
|
+
utcHourEnd: number;
|
|
18
|
+
};
|
|
19
|
+
} | undefined);
|
|
20
|
+
checkAndNotify(): Promise<UpdateManifest>;
|
|
21
|
+
applyUpdates(updates: PackageUpdate[]): Promise<void>;
|
|
22
|
+
isInMaintenanceWindow(): boolean;
|
|
23
|
+
filterByPolicy(updates: PackageUpdate[]): PackageUpdate[];
|
|
24
|
+
}
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { execSync } from 'child_process';
|
|
2
|
+
import { BackupManager } from './backup-manager.js';
|
|
3
|
+
export class UpdateManager {
|
|
4
|
+
checker;
|
|
5
|
+
db;
|
|
6
|
+
hooks;
|
|
7
|
+
opts;
|
|
8
|
+
backupManager;
|
|
9
|
+
constructor(checker, db, hooks, opts) {
|
|
10
|
+
this.checker = checker;
|
|
11
|
+
this.db = db;
|
|
12
|
+
this.hooks = hooks;
|
|
13
|
+
this.opts = opts;
|
|
14
|
+
this.backupManager = new BackupManager(opts?.projectRoot ?? process.cwd());
|
|
15
|
+
}
|
|
16
|
+
async checkAndNotify() {
|
|
17
|
+
const manifest = await this.checker.check();
|
|
18
|
+
if (manifest.hasUpdates) {
|
|
19
|
+
await this.hooks.emit('update.available', { manifest });
|
|
20
|
+
}
|
|
21
|
+
return manifest;
|
|
22
|
+
}
|
|
23
|
+
async applyUpdates(updates) {
|
|
24
|
+
const filtered = this.filterByPolicy(updates);
|
|
25
|
+
if (filtered.length === 0)
|
|
26
|
+
return;
|
|
27
|
+
if (!this.isInMaintenanceWindow()) {
|
|
28
|
+
await this.hooks.emit('update.deferred', { reason: 'outside maintenance window' });
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
let backupPath;
|
|
32
|
+
const historyIds = [];
|
|
33
|
+
try {
|
|
34
|
+
backupPath = await this.backupManager.backup();
|
|
35
|
+
for (const update of filtered) {
|
|
36
|
+
const row = await this.db.insert('update_history', {
|
|
37
|
+
from_version: update.installedVersion,
|
|
38
|
+
to_version: update.latestVersion,
|
|
39
|
+
status: 'pending',
|
|
40
|
+
});
|
|
41
|
+
historyIds.push(row['id']);
|
|
42
|
+
}
|
|
43
|
+
execSync('pnpm install', {
|
|
44
|
+
cwd: this.opts?.projectRoot ?? process.cwd(),
|
|
45
|
+
stdio: 'ignore',
|
|
46
|
+
});
|
|
47
|
+
for (const id of historyIds) {
|
|
48
|
+
await this.db.update('update_history', { id }, { status: 'succeeded' });
|
|
49
|
+
}
|
|
50
|
+
await this.backupManager.cleanup(backupPath);
|
|
51
|
+
await this.hooks.emit('update.completed', { updates: filtered });
|
|
52
|
+
}
|
|
53
|
+
catch (err) {
|
|
54
|
+
for (const id of historyIds) {
|
|
55
|
+
await this.db.update('update_history', { id }, {
|
|
56
|
+
status: 'failed',
|
|
57
|
+
migration_log: String(err),
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
if (backupPath) {
|
|
61
|
+
try {
|
|
62
|
+
await this.backupManager.restore(backupPath);
|
|
63
|
+
await this.backupManager.cleanup(backupPath);
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
// best effort restore
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
await this.hooks.emit('update.failed', { updates: filtered, error: String(err) });
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
isInMaintenanceWindow() {
|
|
73
|
+
const window = this.opts?.maintenanceWindow;
|
|
74
|
+
if (!window)
|
|
75
|
+
return true; // No window configured = always allowed
|
|
76
|
+
const nowHour = new Date().getUTCHours();
|
|
77
|
+
const { utcHourStart, utcHourEnd } = window;
|
|
78
|
+
if (utcHourStart <= utcHourEnd) {
|
|
79
|
+
return nowHour >= utcHourStart && nowHour < utcHourEnd;
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
// Wraps midnight
|
|
83
|
+
return nowHour >= utcHourStart || nowHour < utcHourEnd;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
filterByPolicy(updates) {
|
|
87
|
+
const policy = this.opts?.policy ?? 'notify';
|
|
88
|
+
switch (policy) {
|
|
89
|
+
case 'auto-all':
|
|
90
|
+
return updates;
|
|
91
|
+
case 'auto-compatible':
|
|
92
|
+
return updates.filter((u) => u.updateType !== 'major');
|
|
93
|
+
case 'auto-patch':
|
|
94
|
+
return updates.filter((u) => u.updateType === 'patch');
|
|
95
|
+
case 'notify':
|
|
96
|
+
case 'manual':
|
|
97
|
+
default:
|
|
98
|
+
return [];
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Simple semver utilities — no external deps.
|
|
3
|
+
*/
|
|
4
|
+
export declare function parseVersion(v: string): [number, number, number];
|
|
5
|
+
export declare function compareVersions(a: string, b: string): -1 | 0 | 1;
|
|
6
|
+
export declare function classifyUpdate(from: string, to: string): 'patch' | 'minor' | 'major' | 'none';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Simple semver utilities — no external deps.
|
|
3
|
+
*/
|
|
4
|
+
export function parseVersion(v) {
|
|
5
|
+
// Strip leading 'v' and any pre-release suffix
|
|
6
|
+
const cleaned = v.replace(/^v/, '').split('-')[0] ?? v;
|
|
7
|
+
const parts = cleaned.split('.');
|
|
8
|
+
const major = parseInt(parts[0] ?? '0', 10) || 0;
|
|
9
|
+
const minor = parseInt(parts[1] ?? '0', 10) || 0;
|
|
10
|
+
const patch = parseInt(parts[2] ?? '0', 10) || 0;
|
|
11
|
+
return [major, minor, patch];
|
|
12
|
+
}
|
|
13
|
+
export function compareVersions(a, b) {
|
|
14
|
+
const [aMaj, aMin, aPat] = parseVersion(a);
|
|
15
|
+
const [bMaj, bMin, bPat] = parseVersion(b);
|
|
16
|
+
if (aMaj !== bMaj)
|
|
17
|
+
return aMaj < bMaj ? -1 : 1;
|
|
18
|
+
if (aMin !== bMin)
|
|
19
|
+
return aMin < bMin ? -1 : 1;
|
|
20
|
+
if (aPat !== bPat)
|
|
21
|
+
return aPat < bPat ? -1 : 1;
|
|
22
|
+
return 0;
|
|
23
|
+
}
|
|
24
|
+
export function classifyUpdate(from, to) {
|
|
25
|
+
const [fMaj, fMin] = parseVersion(from);
|
|
26
|
+
const [tMaj, tMin] = parseVersion(to);
|
|
27
|
+
if (compareVersions(from, to) === 0)
|
|
28
|
+
return 'none';
|
|
29
|
+
if (tMaj !== fMaj)
|
|
30
|
+
return 'major';
|
|
31
|
+
if (tMin !== fMin)
|
|
32
|
+
return 'minor';
|
|
33
|
+
return 'patch';
|
|
34
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -2166,6 +2166,16 @@ declare const searchConversationTool: {
|
|
|
2166
2166
|
handler: ToolHandler;
|
|
2167
2167
|
};
|
|
2168
2168
|
|
|
2169
|
+
/**
|
|
2170
|
+
* Shared agent resolution: slug → role → name (case-insensitive).
|
|
2171
|
+
*
|
|
2172
|
+
* LLMs see list_agents output like "AgentName (role)" and naturally use
|
|
2173
|
+
* the role as the identifier. All agent-resolving tools must accept
|
|
2174
|
+
* slug, role, OR name — not just slug.
|
|
2175
|
+
*/
|
|
2176
|
+
|
|
2177
|
+
declare function resolveAgent(db: DataStore, ref: string): Promise<Record<string, unknown> | null>;
|
|
2178
|
+
|
|
2169
2179
|
/**
|
|
2170
2180
|
* Built-in tools: Entity creation — agents, projects.
|
|
2171
2181
|
*/
|
|
@@ -2290,4 +2300,4 @@ declare function isLoginRequired(stdout: string): boolean;
|
|
|
2290
2300
|
/** Rewrite local image paths to prevent CLI auto-embedding as vision content. */
|
|
2291
2301
|
declare function deactivateLocalImagePaths(prompt: string): string;
|
|
2292
2302
|
|
|
2293
|
-
export { AGENT_STATUSES, type AgentConfig, type AgentDefinition, type AgentFilter, type AgentRecord, AgentRegistry, type AgentStatus, ApiExecutionAdapter, type ApprovalResponse, type ApprovalStatus, AuditEmitter, type AuditEvent, BackupManager, type BotConfig, BreakerState, type BudgetCheck, type BudgetConfig, BudgetController, CORE_MIGRATIONS, ChannelAdapter, ChannelRegistry, ChannelRegistryError, type ChatConfig, ChatMessage, ChatPipelineV2, type ChatPipelineV2Config, ChatResponder, ChatResponderConfig, ChatSessionManager, CircuitBreaker, type CircuitBreakerConfig, CliExecutionAdapter, type ColumnValidator, ColumnValidatorImpl, type ConfigLoadError, type ConfigLoadResult, ConnectorConfig, DEFAULTS, DEFAULT_CONFIG, type DataConfig, DataStore, type DefaultLLMCallConfig, DeterministicAdapter, type DeterministicConfig, type DomainEntityContextOptions, type DomainSchemaOptions, DriftGate, EVENTS, type EntityColumnDef, type EntityConfig, type ExecutionAdapter, type ExecutionConfig, type ExecutionEngineConfig, Extractor, type FeedbackEntry, type GateFinding, type GateInput, type GateResult, GateRunner, type GateVerdict, GovernanceGate, HealthStatus, HookBus, InboundMessage, LLMProvider, LearningPipeline, type LearningPipelineConfig, type LoopDetection, LoopDetector, type LoopDetectorConfig, LoopType, MAX_CHAIN_DEPTH, MessageInterpreter, MessagePipeline, MessageStore, type ModelConfig, ModelInfo, ModelRouter, NdjsonLogger, NotificationQueue, type PackageMigration, type PackageUpdate, type ParsedStream, type PermissionPrompt, type PermissionProvider, PermissionRelay, type PermissionRelayConfig, type PlaybookEntry, ProviderRegistry, QAGate, QualityGate, RUN_STATUSES, type RenderConfig, ResolvedModel, type RetryPolicy, type RoutingConfig, type RunContext, RunManager, type RunResult, type RunStatus, type SafetyConfig, type SanitizerOptions, type Schedule, type ScheduleDef, Scheduler, type SchemaError, type SecretInput, type SecretMeta, SecretStore, type SecurityConfig, SessionKey, SessionManager, type SkillEntry, type StepRef, type SystemContextOptions, TASK_STATUSES, type TaskDefinition, TaskQueue, type TaskRecord, type TaskStatus, TokenUsage, type ToolContext, type ToolDefinition, type ToolHandler, UpdateChecker, type UpdateConfig, UpdateManager, type UpdateManifest, type UsageSummary, type User, type UserInput, UserRegistry, WakeupQueue, type WorkflowConfigEntry, type WorkflowDefinition$1 as WorkflowDefinition, WorkflowEngine, type WorkflowRunRecord, type WorkflowRunStatus, type WorkflowStep$1 as WorkflowStep, type WorkflowStepConfig, type WorkflowTrigger, _resetConfig, addTaskCommentTool, areDependenciesMet, autoUpdate, buildAgentBindings, buildChainOrigin, buildProcessEnv, buildSystemContext, cancelTaskTool, checkAllowlist, checkChainDepth, checkMentionGate, chunkText, classifyUpdate, compareVersions, coordinatorTools, createAgentTool, createConfigRevision, createDefaultLLMCall, createProjectTool, deactivateLocalImagePaths, defineCoreEntityContexts, defineCoreTables, defineDomainEntityContexts, defineDomainTables, detectCycle, discoverChannels, discoverProviders, dispatchTaskTool, formatText, getActiveTasksTool, getAgentDetailTool, getAgentStatusTool, getConfig, getSystemStatusTool, getTaskStatusTool, initConfig, interpolate, interpolateEnv, isLoginRequired, isMaxTurns, listAgentsTool, listFilesTool, listProjectsTool, loadConfig, nativeTools, parseClaudeStream, parseVersion, readConversationTool, readFileTool, reassignTaskTool, registerExecutionEngine, registerFileTool, runPackageMigrations, sanitize, searchConversationTool, sendFileTool, sendMessageTool, topologicalSort, truncateAtWord, validateConfig };
|
|
2303
|
+
export { AGENT_STATUSES, type AgentConfig, type AgentDefinition, type AgentFilter, type AgentRecord, AgentRegistry, type AgentStatus, ApiExecutionAdapter, type ApprovalResponse, type ApprovalStatus, AuditEmitter, type AuditEvent, BackupManager, type BotConfig, BreakerState, type BudgetCheck, type BudgetConfig, BudgetController, CORE_MIGRATIONS, ChannelAdapter, ChannelRegistry, ChannelRegistryError, type ChatConfig, ChatMessage, ChatPipelineV2, type ChatPipelineV2Config, ChatResponder, ChatResponderConfig, ChatSessionManager, CircuitBreaker, type CircuitBreakerConfig, CliExecutionAdapter, type ColumnValidator, ColumnValidatorImpl, type ConfigLoadError, type ConfigLoadResult, ConnectorConfig, DEFAULTS, DEFAULT_CONFIG, type DataConfig, DataStore, type DefaultLLMCallConfig, DeterministicAdapter, type DeterministicConfig, type DomainEntityContextOptions, type DomainSchemaOptions, DriftGate, EVENTS, type EntityColumnDef, type EntityConfig, type ExecutionAdapter, type ExecutionConfig, type ExecutionEngineConfig, Extractor, type FeedbackEntry, type GateFinding, type GateInput, type GateResult, GateRunner, type GateVerdict, GovernanceGate, HealthStatus, HookBus, InboundMessage, LLMProvider, LearningPipeline, type LearningPipelineConfig, type LoopDetection, LoopDetector, type LoopDetectorConfig, LoopType, MAX_CHAIN_DEPTH, MessageInterpreter, MessagePipeline, MessageStore, type ModelConfig, ModelInfo, ModelRouter, NdjsonLogger, NotificationQueue, type PackageMigration, type PackageUpdate, type ParsedStream, type PermissionPrompt, type PermissionProvider, PermissionRelay, type PermissionRelayConfig, type PlaybookEntry, ProviderRegistry, QAGate, QualityGate, RUN_STATUSES, type RenderConfig, ResolvedModel, type RetryPolicy, type RoutingConfig, type RunContext, RunManager, type RunResult, type RunStatus, type SafetyConfig, type SanitizerOptions, type Schedule, type ScheduleDef, Scheduler, type SchemaError, type SecretInput, type SecretMeta, SecretStore, type SecurityConfig, SessionKey, SessionManager, type SkillEntry, type StepRef, type SystemContextOptions, TASK_STATUSES, type TaskDefinition, TaskQueue, type TaskRecord, type TaskStatus, TokenUsage, type ToolContext, type ToolDefinition, type ToolHandler, UpdateChecker, type UpdateConfig, UpdateManager, type UpdateManifest, type UsageSummary, type User, type UserInput, UserRegistry, WakeupQueue, type WorkflowConfigEntry, type WorkflowDefinition$1 as WorkflowDefinition, WorkflowEngine, type WorkflowRunRecord, type WorkflowRunStatus, type WorkflowStep$1 as WorkflowStep, type WorkflowStepConfig, type WorkflowTrigger, _resetConfig, addTaskCommentTool, areDependenciesMet, autoUpdate, buildAgentBindings, buildChainOrigin, buildProcessEnv, buildSystemContext, cancelTaskTool, checkAllowlist, checkChainDepth, checkMentionGate, chunkText, classifyUpdate, compareVersions, coordinatorTools, createAgentTool, createConfigRevision, createDefaultLLMCall, createProjectTool, deactivateLocalImagePaths, defineCoreEntityContexts, defineCoreTables, defineDomainEntityContexts, defineDomainTables, detectCycle, discoverChannels, discoverProviders, dispatchTaskTool, formatText, getActiveTasksTool, getAgentDetailTool, getAgentStatusTool, getConfig, getSystemStatusTool, getTaskStatusTool, initConfig, interpolate, interpolateEnv, isLoginRequired, isMaxTurns, listAgentsTool, listFilesTool, listProjectsTool, loadConfig, nativeTools, parseClaudeStream, parseVersion, readConversationTool, readFileTool, reassignTaskTool, registerExecutionEngine, registerFileTool, resolveAgent, runPackageMigrations, sanitize, searchConversationTool, sendFileTool, sendMessageTool, topologicalSort, truncateAtWord, validateConfig };
|
package/dist/index.js
CHANGED
|
@@ -6685,6 +6685,25 @@ var registerFileTool = {
|
|
|
6685
6685
|
|
|
6686
6686
|
// src/core/orchestrator/tools/task-ops.ts
|
|
6687
6687
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
6688
|
+
|
|
6689
|
+
// src/core/orchestrator/tools/resolve-agent.ts
|
|
6690
|
+
async function resolveAgent(db, ref) {
|
|
6691
|
+
const bySlug = await db.query("agents", { where: { slug: ref } });
|
|
6692
|
+
if (bySlug[0] && !bySlug[0].deleted_at) return bySlug[0];
|
|
6693
|
+
const byRole = await db.query("agents", { where: { role: ref } });
|
|
6694
|
+
const activeByRole = byRole.find((a) => !a.deleted_at);
|
|
6695
|
+
if (activeByRole) return activeByRole;
|
|
6696
|
+
const byName = await db.query("agents", { where: { name: ref } });
|
|
6697
|
+
const activeByName = byName.find((a) => !a.deleted_at);
|
|
6698
|
+
if (activeByName) return activeByName;
|
|
6699
|
+
const lower = ref.toLowerCase();
|
|
6700
|
+
const all = await db.query("agents");
|
|
6701
|
+
return all.find(
|
|
6702
|
+
(a) => !a.deleted_at && (a.slug?.toLowerCase() === lower || a.role?.toLowerCase() === lower || a.name?.toLowerCase() === lower)
|
|
6703
|
+
) ?? null;
|
|
6704
|
+
}
|
|
6705
|
+
|
|
6706
|
+
// src/core/orchestrator/tools/task-ops.ts
|
|
6688
6707
|
var dispatchTaskTool = {
|
|
6689
6708
|
definition: {
|
|
6690
6709
|
name: "dispatch_task",
|
|
@@ -6694,15 +6713,14 @@ var dispatchTaskTool = {
|
|
|
6694
6713
|
properties: {
|
|
6695
6714
|
title: { type: "string", description: "Short task title" },
|
|
6696
6715
|
description: { type: "string", description: "Detailed task description" },
|
|
6697
|
-
agent_slug: { type: "string", description: 'Agent slug
|
|
6716
|
+
agent_slug: { type: "string", description: 'Agent slug, role, or name (e.g. "eddy", "engineer", "Eddy")' },
|
|
6698
6717
|
priority: { type: "number", description: "Priority 1-10 (lower = higher priority). Default: 5" }
|
|
6699
6718
|
},
|
|
6700
6719
|
required: ["title", "agent_slug"]
|
|
6701
6720
|
}
|
|
6702
6721
|
},
|
|
6703
6722
|
handler: async (input, ctx) => {
|
|
6704
|
-
const
|
|
6705
|
-
const agent = agents[0];
|
|
6723
|
+
const agent = await resolveAgent(ctx.db, input.agent_slug);
|
|
6706
6724
|
if (!agent) return `Error: agent "${input.agent_slug}" not found.`;
|
|
6707
6725
|
const row = await ctx.db.insert("tasks", {
|
|
6708
6726
|
id: randomUUID2(),
|
|
@@ -6742,7 +6760,7 @@ var reassignTaskTool = {
|
|
|
6742
6760
|
type: "object",
|
|
6743
6761
|
properties: {
|
|
6744
6762
|
task_id: { type: "string", description: "Task ID to reassign" },
|
|
6745
|
-
new_agent_slug: { type: "string", description: "Agent slug to reassign to" }
|
|
6763
|
+
new_agent_slug: { type: "string", description: "Agent slug, role, or name to reassign to" }
|
|
6746
6764
|
},
|
|
6747
6765
|
required: ["task_id", "new_agent_slug"]
|
|
6748
6766
|
}
|
|
@@ -6750,8 +6768,7 @@ var reassignTaskTool = {
|
|
|
6750
6768
|
handler: async (input, ctx) => {
|
|
6751
6769
|
const task = await ctx.db.get("tasks", { id: input.task_id });
|
|
6752
6770
|
if (!task) return `Error: task ${input.task_id} not found.`;
|
|
6753
|
-
const
|
|
6754
|
-
const newAgent = agents[0];
|
|
6771
|
+
const newAgent = await resolveAgent(ctx.db, input.new_agent_slug);
|
|
6755
6772
|
if (!newAgent) return `Error: agent "${input.new_agent_slug}" not found.`;
|
|
6756
6773
|
await ctx.db.update("tasks", { id: input.task_id }, { status: "cancelled" });
|
|
6757
6774
|
const row = await ctx.db.insert("tasks", {
|
|
@@ -6799,14 +6816,13 @@ var getAgentStatusTool = {
|
|
|
6799
6816
|
input_schema: {
|
|
6800
6817
|
type: "object",
|
|
6801
6818
|
properties: {
|
|
6802
|
-
agent_slug: { type: "string", description: 'Agent slug (e.g. "engineer")' }
|
|
6819
|
+
agent_slug: { type: "string", description: 'Agent slug, role, or name (e.g. "eddy", "engineer", "Eddy")' }
|
|
6803
6820
|
},
|
|
6804
6821
|
required: ["agent_slug"]
|
|
6805
6822
|
}
|
|
6806
6823
|
},
|
|
6807
6824
|
handler: async (input, ctx) => {
|
|
6808
|
-
const
|
|
6809
|
-
const agent = agents[0];
|
|
6825
|
+
const agent = await resolveAgent(ctx.db, input.agent_slug);
|
|
6810
6826
|
if (!agent) return `Agent "${input.agent_slug}" not found.`;
|
|
6811
6827
|
const tasks = await ctx.db.query("tasks", { where: { assignee_id: agent.id, status: "todo" } });
|
|
6812
6828
|
const runs = await ctx.db.query("runs", { where: { agent_id: agent.id }, limit: 5 });
|
|
@@ -6890,8 +6906,7 @@ var getAgentDetailTool = {
|
|
|
6890
6906
|
}
|
|
6891
6907
|
},
|
|
6892
6908
|
handler: async (input, ctx) => {
|
|
6893
|
-
const
|
|
6894
|
-
const agent = agents[0];
|
|
6909
|
+
const agent = await resolveAgent(ctx.db, input.agent_slug);
|
|
6895
6910
|
if (!agent) return `Agent "${input.agent_slug}" not found.`;
|
|
6896
6911
|
const skills = await ctx.db.query("agent_skills", { where: { agent_id: agent.id } }).catch(() => []);
|
|
6897
6912
|
const skillNames = [];
|
|
@@ -7567,6 +7582,7 @@ export {
|
|
|
7567
7582
|
reassignTaskTool,
|
|
7568
7583
|
registerExecutionEngine,
|
|
7569
7584
|
registerFileTool,
|
|
7585
|
+
resolveAgent,
|
|
7570
7586
|
runPackageMigrations,
|
|
7571
7587
|
sanitize,
|
|
7572
7588
|
searchConversationTool,
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/** LLM provider types — Story 1.5 / 2.1 */
|
|
2
|
+
interface ToolDefinition {
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
parameters: Record<string, unknown>;
|
|
6
|
+
}
|
|
7
|
+
interface ChatMessage {
|
|
8
|
+
role: "user" | "assistant" | "system";
|
|
9
|
+
content: string | ContentBlock[];
|
|
10
|
+
}
|
|
11
|
+
type ContentBlock = {
|
|
12
|
+
type: "text";
|
|
13
|
+
text: string;
|
|
14
|
+
} | {
|
|
15
|
+
type: "tool_use";
|
|
16
|
+
id: string;
|
|
17
|
+
name: string;
|
|
18
|
+
input: unknown;
|
|
19
|
+
} | {
|
|
20
|
+
type: "tool_result";
|
|
21
|
+
tool_use_id: string;
|
|
22
|
+
content: string;
|
|
23
|
+
};
|
|
24
|
+
interface ChatParams {
|
|
25
|
+
messages: ChatMessage[];
|
|
26
|
+
system?: string;
|
|
27
|
+
tools?: ToolDefinition[];
|
|
28
|
+
maxTokens?: number;
|
|
29
|
+
temperature?: number;
|
|
30
|
+
model: string;
|
|
31
|
+
abortSignal?: AbortSignal;
|
|
32
|
+
}
|
|
33
|
+
interface TokenUsage {
|
|
34
|
+
inputTokens: number;
|
|
35
|
+
outputTokens: number;
|
|
36
|
+
cacheReadTokens?: number;
|
|
37
|
+
cacheWriteTokens?: number;
|
|
38
|
+
}
|
|
39
|
+
interface ChatResult {
|
|
40
|
+
content: string;
|
|
41
|
+
toolUses?: ToolUse[];
|
|
42
|
+
usage: TokenUsage;
|
|
43
|
+
model: string;
|
|
44
|
+
stopReason: "end_turn" | "tool_use" | "max_tokens" | "stop_sequence";
|
|
45
|
+
}
|
|
46
|
+
interface ToolUse {
|
|
47
|
+
id: string;
|
|
48
|
+
name: string;
|
|
49
|
+
input: unknown;
|
|
50
|
+
}
|
|
51
|
+
interface ModelInfo {
|
|
52
|
+
id: string;
|
|
53
|
+
displayName: string;
|
|
54
|
+
contextWindow: number;
|
|
55
|
+
maxOutputTokens: number;
|
|
56
|
+
capabilities: Array<"chat" | "tools" | "vision" | "streaming">;
|
|
57
|
+
/** Cost in micro-cents per 1M tokens */
|
|
58
|
+
inputCostPerMToken?: number;
|
|
59
|
+
outputCostPerMToken?: number;
|
|
60
|
+
}
|
|
61
|
+
interface ResolvedModel {
|
|
62
|
+
provider: string;
|
|
63
|
+
model: string;
|
|
64
|
+
}
|
|
65
|
+
interface LLMProvider {
|
|
66
|
+
id: string;
|
|
67
|
+
displayName: string;
|
|
68
|
+
models: ModelInfo[];
|
|
69
|
+
chat(params: ChatParams): Promise<ChatResult>;
|
|
70
|
+
chatStream(params: ChatParams): AsyncGenerator<string, ChatResult, unknown>;
|
|
71
|
+
/** Convert ToolDefinition[] to provider-native format */
|
|
72
|
+
serializeTools(tools: ToolDefinition[]): unknown;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export type { ChatMessage as C, LLMProvider as L, ModelInfo as M, ResolvedModel as R, TokenUsage as T, ChatParams as a, ChatResult as b, ContentBlock as c, ToolDefinition as d, ToolUse as e };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export const MODELS = [
|
|
2
|
+
{
|
|
3
|
+
id: 'claude-opus-4-6',
|
|
4
|
+
displayName: 'Claude Opus 4.6',
|
|
5
|
+
contextWindow: 200000,
|
|
6
|
+
maxOutputTokens: 32000,
|
|
7
|
+
inputCostPerMToken: 15,
|
|
8
|
+
outputCostPerMToken: 75,
|
|
9
|
+
capabilities: ['chat', 'tools', 'vision', 'streaming'],
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
id: 'claude-sonnet-4-6',
|
|
13
|
+
displayName: 'Claude Sonnet 4.6',
|
|
14
|
+
contextWindow: 200000,
|
|
15
|
+
maxOutputTokens: 16000,
|
|
16
|
+
inputCostPerMToken: 3,
|
|
17
|
+
outputCostPerMToken: 15,
|
|
18
|
+
capabilities: ['chat', 'tools', 'vision', 'streaming'],
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
id: 'claude-haiku-4-5',
|
|
22
|
+
displayName: 'Claude Haiku 4.5',
|
|
23
|
+
contextWindow: 200000,
|
|
24
|
+
maxOutputTokens: 8192,
|
|
25
|
+
inputCostPerMToken: 0.8,
|
|
26
|
+
outputCostPerMToken: 4,
|
|
27
|
+
capabilities: ['chat', 'tools', 'vision', 'streaming'],
|
|
28
|
+
},
|
|
29
|
+
];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { LLMProvider, ChatParams, ChatResult, ModelInfo, ToolDefinition } from "../../shared/index.js";
|
|
2
|
+
export declare class AnthropicProvider implements LLMProvider {
|
|
3
|
+
readonly id = "anthropic";
|
|
4
|
+
readonly displayName = "Anthropic";
|
|
5
|
+
readonly models: ModelInfo[];
|
|
6
|
+
private client;
|
|
7
|
+
constructor({ apiKey }: {
|
|
8
|
+
apiKey: string;
|
|
9
|
+
});
|
|
10
|
+
serializeTools(tools: ToolDefinition[]): unknown;
|
|
11
|
+
chat(params: ChatParams): Promise<ChatResult>;
|
|
12
|
+
chatStream(params: ChatParams): AsyncGenerator<string, ChatResult, unknown>;
|
|
13
|
+
}
|