diff --git a/ts/packages/cli/package.json b/ts/packages/cli/package.json index 2ea25696f..87a166e2b 100644 --- a/ts/packages/cli/package.json +++ b/ts/packages/cli/package.json @@ -56,6 +56,7 @@ "@typeagent/agent-sdk": "workspace:*", "@typeagent/agent-server-client": "workspace:*", "@typeagent/common-utils": "workspace:*", + "@typeagent/dispatcher-types": "workspace:*", "action-grammar": "workspace:*", "agent-cache": "workspace:*", "agent-dispatcher": "workspace:*", diff --git a/ts/packages/cli/src/commands/connect.ts b/ts/packages/cli/src/commands/connect.ts index fdc2a12e5..2f92da8af 100644 --- a/ts/packages/cli/src/commands/connect.ts +++ b/ts/packages/cli/src/commands/connect.ts @@ -1,13 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -// TODO: The CLI still depends on agent-dispatcher for types (Dispatcher, ClientIO, -// RequestId, etc.) and helpers (withConsoleClientIO, getStatusSummary). These types -// should eventually be moved to @typeagent/dispatcher-types to avoid the heavyweight -// dependency. See cli-agent-server-deprecation.md Phase 5. - import { Args, Command, Flags } from "@oclif/core"; -import { Dispatcher } from "agent-dispatcher"; +import type { Dispatcher } from "@typeagent/dispatcher-types"; import { getEnhancedConsolePrompt, processCommandsEnhanced, @@ -21,7 +16,7 @@ import { ensureAndConnectSession, AgentServerConnection, } from "@typeagent/agent-server-client"; -import { getStatusSummary } from "agent-dispatcher/helpers/status"; +import { getStatusSummary } from "@typeagent/dispatcher-types/helpers/status"; import * as crypto from "crypto"; import * as fs from "fs"; import * as os from "os"; diff --git a/ts/packages/cli/src/enhancedConsole.ts b/ts/packages/cli/src/enhancedConsole.ts index f41e64ba3..27a0dee08 100644 --- a/ts/packages/cli/src/enhancedConsole.ts +++ b/ts/packages/cli/src/enhancedConsole.ts @@ -28,7 +28,7 @@ import type { PendingInteractionRequest, PendingInteractionResponse, PendingInteractionEntry, -} from "agent-dispatcher"; +} from "@typeagent/dispatcher-types"; import chalk from "chalk"; import fs from "fs"; import path from "path"; diff --git a/ts/packages/cli/test/multiClientInteraction.spec.ts b/ts/packages/cli/test/multiClientInteraction.spec.ts index df86ecb23..de95ae8fd 100644 --- a/ts/packages/cli/test/multiClientInteraction.spec.ts +++ b/ts/packages/cli/test/multiClientInteraction.spec.ts @@ -23,7 +23,10 @@ import { describe, it, expect, beforeEach, afterEach } from "@jest/globals"; import { EventEmitter } from "node:events"; import { createEnhancedClientIO } from "../src/enhancedConsole.js"; -import type { PendingInteractionRequest, Dispatcher } from "agent-dispatcher"; +import type { + PendingInteractionRequest, + Dispatcher, +} from "@typeagent/dispatcher-types"; // ── Stdin/stdout stubs ─────────────────────────────────────────────────────── diff --git a/ts/packages/dispatcher/dispatcher/src/context/dispatcher/dispatcherUtils.ts b/ts/packages/dispatcher/dispatcher/src/context/dispatcher/dispatcherUtils.ts index 04ce2cf70..ea8c1a1d4 100644 --- a/ts/packages/dispatcher/dispatcher/src/context/dispatcher/dispatcherUtils.ts +++ b/ts/packages/dispatcher/dispatcher/src/context/dispatcher/dispatcherUtils.ts @@ -3,11 +3,11 @@ import { AppAction } from "@typeagent/agent-sdk"; import { UnknownAction } from "./schema/dispatcherActionSchema.js"; +import { DispatcherName, DispatcherEmoji } from "@typeagent/dispatcher-types"; -export const DispatcherName = "dispatcher"; +export { DispatcherName, DispatcherEmoji }; export const DispatcherClarifyName = "dispatcher.clarify"; export const DispatcherActivityName = "dispatcher.activity"; -export const DispatcherEmoji = "🤖"; export function isUnknownAction(action: AppAction): action is UnknownAction { return action.actionName === "unknown"; diff --git a/ts/packages/dispatcher/dispatcher/src/helpers/status.ts b/ts/packages/dispatcher/dispatcher/src/helpers/status.ts index a4c17a366..c55c837d1 100644 --- a/ts/packages/dispatcher/dispatcher/src/helpers/status.ts +++ b/ts/packages/dispatcher/dispatcher/src/helpers/status.ts @@ -1,38 +1,4 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { - DispatcherEmoji, - DispatcherName, -} from "../context/dispatcher/dispatcherUtils.js"; -import type { DispatcherStatus } from "@typeagent/dispatcher-types"; - -export function getStatusSummary( - state: DispatcherStatus, - options?: { - showPrimaryName?: boolean; // default true - }, -): string { - const active: string[] = []; - const showPrimaryName = options?.showPrimaryName ?? true; - let primary: string = showPrimaryName - ? `${DispatcherEmoji} ${DispatcherName} - ` - : `${DispatcherEmoji}:`; - for (const agent of state.agents) { - if (agent.request && agent.name !== DispatcherName) { - return `{{${agent.emoji} ${agent.name.toUpperCase()}}}`; - } - if (agent.lastUsed) { - active.unshift(agent.emoji); - } - if (agent.active) { - active.push(agent.emoji); - } - if (agent.priority) { - primary = showPrimaryName - ? `${agent.emoji} ${agent.name} - ` - : `${agent.emoji}:`; - } - } - return `${primary}[${Array.from(new Set(active)).join("")} ]${state.details}`; -} +export { getStatusSummary } from "@typeagent/dispatcher-types/helpers/status"; diff --git a/ts/packages/dispatcher/nodeProviders/package.json b/ts/packages/dispatcher/nodeProviders/package.json index 92565b3e7..11fc37ebd 100644 --- a/ts/packages/dispatcher/nodeProviders/package.json +++ b/ts/packages/dispatcher/nodeProviders/package.json @@ -39,6 +39,7 @@ "debug": "^4.4.0" }, "devDependencies": { + "@typeagent/dispatcher-types": "workspace:*", "@types/debug": "^4.1.12", "@types/jest": "^29.5.7", "jest": "^29.7.0", diff --git a/ts/packages/dispatcher/nodeProviders/test/provider.spec.ts b/ts/packages/dispatcher/nodeProviders/test/provider.spec.ts index 19d046e74..029d3f476 100644 --- a/ts/packages/dispatcher/nodeProviders/test/provider.spec.ts +++ b/ts/packages/dispatcher/nodeProviders/test/provider.spec.ts @@ -8,7 +8,7 @@ import type { ClientIO, IAgentMessage, RequestId, -} from "agent-dispatcher"; +} from "@typeagent/dispatcher-types"; import { fileURLToPath } from "node:url"; const testAppAgentProvider = createNpmAppAgentProvider( diff --git a/ts/packages/dispatcher/nodeProviders/test/tsconfig.json b/ts/packages/dispatcher/nodeProviders/test/tsconfig.json index 895a6f0d2..d6406b463 100644 --- a/ts/packages/dispatcher/nodeProviders/test/tsconfig.json +++ b/ts/packages/dispatcher/nodeProviders/test/tsconfig.json @@ -10,5 +10,5 @@ "ts-node": { "esm": true }, - "references": [{ "path": "../src" }] + "references": [{ "path": "../src" }, { "path": "../../types/src" }] } diff --git a/ts/packages/dispatcher/types/package.json b/ts/packages/dispatcher/types/package.json index 437740185..fa0f670ba 100644 --- a/ts/packages/dispatcher/types/package.json +++ b/ts/packages/dispatcher/types/package.json @@ -12,7 +12,8 @@ "author": "Microsoft", "type": "module", "exports": { - ".": "./dist/index.js" + ".": "./dist/index.js", + "./helpers/status": "./dist/helpers/status.js" }, "files": [ "dist", diff --git a/ts/packages/dispatcher/types/src/dispatcher.ts b/ts/packages/dispatcher/types/src/dispatcher.ts index 9e86be76d..2c96f3798 100644 --- a/ts/packages/dispatcher/types/src/dispatcher.ts +++ b/ts/packages/dispatcher/types/src/dispatcher.ts @@ -13,6 +13,9 @@ import { import type { DisplayLogEntry } from "./displayLogEntry.js"; import type { PendingInteractionResponse } from "./pendingInteraction.js"; +export const DispatcherName = "dispatcher"; +export const DispatcherEmoji = "🤖"; + /** * Identifies a command request across the dispatcher and all connected clients. * diff --git a/ts/packages/dispatcher/types/src/helpers/status.ts b/ts/packages/dispatcher/types/src/helpers/status.ts new file mode 100644 index 000000000..eeddaa0bb --- /dev/null +++ b/ts/packages/dispatcher/types/src/helpers/status.ts @@ -0,0 +1,38 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { + DispatcherEmoji, + DispatcherName, + type DispatcherStatus, +} from "../dispatcher.js"; + +export function getStatusSummary( + state: DispatcherStatus, + options?: { + showPrimaryName?: boolean; // default true + }, +): string { + const active: string[] = []; + const showPrimaryName = options?.showPrimaryName ?? true; + let primary: string = showPrimaryName + ? `${DispatcherEmoji} ${DispatcherName} - ` + : `${DispatcherEmoji}:`; + for (const agent of state.agents) { + if (agent.request && agent.name !== DispatcherName) { + return `{{${agent.emoji} ${agent.name.toUpperCase()}}}`; + } + if (agent.lastUsed) { + active.unshift(agent.emoji); + } + if (agent.active) { + active.push(agent.emoji); + } + if (agent.priority) { + primary = showPrimaryName + ? `${agent.emoji} ${agent.name} - ` + : `${agent.emoji}:`; + } + } + return `${primary}[${Array.from(new Set(active)).join("")} ]${state.details}`; +} diff --git a/ts/pnpm-lock.yaml b/ts/pnpm-lock.yaml index b39dcd890..cf378c23c 100644 --- a/ts/pnpm-lock.yaml +++ b/ts/pnpm-lock.yaml @@ -3057,6 +3057,9 @@ importers: '@typeagent/common-utils': specifier: workspace:* version: link:../utils/commonUtils + '@typeagent/dispatcher-types': + specifier: workspace:* + version: link:../dispatcher/types action-grammar: specifier: workspace:* version: link:../actionGrammar @@ -3656,6 +3659,9 @@ importers: specifier: ^4.4.0 version: 4.4.3(supports-color@8.1.1) devDependencies: + '@typeagent/dispatcher-types': + specifier: workspace:* + version: link:../types '@types/debug': specifier: ^4.1.12 version: 4.1.12