File size: 31,064 Bytes
4e23b01 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 | /**
* Compile-time parity checks between klient wire schemas and the engine
* types they mirror. Plain `.ts` (not `.test.ts`) β vitest must not pick it
* up; `tsc -p tsconfig.json --noEmit` is the check.
*
* Wire shapes are reached through indexed access on the engine service
* interfaces, so klient needs no direct dependency for most of them.
*/
import type { z } from 'zod';
import type { AgentContextData } from '@moonshot-ai/agent-core-v2/agent/contextMemory/types';
import type { IAgentCommandService } from '@moonshot-ai/agent-core-v2/agent/command/agentCommand';
import type { IAgentRuntimeBindingService } from '@moonshot-ai/agent-core-v2/agent/runtimeBinding/runtimeBinding';
import type { TurnEndReason } from '@moonshot-ai/agent-core-v2/agent/loop/turnEvents';
import type { SessionActivityState } from '@moonshot-ai/agent-core-v2/session/sessionActivity/sessionActivity';
import type { PermissionMode } from '@moonshot-ai/agent-core-v2/agent/permissionPolicy/types';
import type { IAgentProfileService } from '@moonshot-ai/agent-core-v2/agent/profile/profile';
import type { PromptLaunchResult, PromptPayload, SteerPayload } from '@moonshot-ai/agent-core-v2/agent/loop/loop';
import type { IAgentShellCommandService } from '@moonshot-ai/agent-core-v2/agent/shellCommand/shellCommand';
import type { IAgentSkillService } from '@moonshot-ai/agent-core-v2/features/skill/skillService';
import type { ContentPart } from '@moonshot-ai/agent-core-v2/human/llm/message';
import type { PlanData } from '@moonshot-ai/agent-core-v2/features/plan/plan';
import type { UsageStatus } from '@moonshot-ai/agent-core-v2/agent/usage/usage';
import type { SkillSummary } from '@moonshot-ai/agent-core-v2/features/skill/catalog/types';
import type { McpServerEntry } from '@moonshot-ai/agent-core-v2/mcpCore/connection-manager';
import type {
GlobalMcpServerConfig,
McpAuthStatusQuery,
McpManagedServer,
McpServerAuthBeginResult,
McpServerAuthFlowHandle,
McpServerAuthState,
McpServerAuthStatus,
McpServerInspection,
McpServerLocator,
McpServerTestResult,
McpServerTestTarget,
} from '@moonshot-ai/agent-core-v2/app/mcpManagement/mcpManagement';
import type {
McpRegistryPluginOrigin,
McpRegistryQuery,
McpServerSource,
} from '@moonshot-ai/agent-core-v2/app/mcpRegistry/mcpRegistry';
import type { McpServerConfig } from '@moonshot-ai/agent-core-v2/mcpCore/config-schema';
import type { McpServerConfigView } from '@moonshot-ai/agent-core-v2/mcpCore/configView';
import type { FullCompactionInput } from '@moonshot-ai/agent-core-v2/agent/fullCompaction/fullCompaction';
import type { ISessionScopeHandle } from '@moonshot-ai/agent-core-v2/_base/di/scope';
import type {
CreateChildSessionOptions,
CreateSessionOptions,
ForkSessionOptions,
ResumeSessionOptions,
} from '@moonshot-ai/agent-core-v2/workspace/sessionLifecycle/sessionLifecycle';
import type {
ApprovalRequest,
ApprovalResponse,
} from '@moonshot-ai/agent-core-v2/agent/interaction/approval';
import type {
Interaction,
InteractionResolution,
} from '@moonshot-ai/agent-core-v2/human/interaction/interaction';
import type {
QuestionAnswers,
QuestionItem,
QuestionOption,
QuestionRequest,
QuestionResponse,
QuestionResult,
} from '@moonshot-ai/agent-core-v2/agent/interaction/question';
import type {
AgentMeta,
SessionMeta,
SessionMetadataChangedEvent,
SessionMetaPatch,
} from '@moonshot-ai/agent-core-v2/session/sessionMetadata/sessionMetadata';
import type { ISessionTitleService } from '@moonshot-ai/agent-core-v2/session/sessionTitle/sessionTitle';
import type {
AuthStatus,
IOAuthService,
} from '@moonshot-ai/agent-core-v2/app/auth/auth';
import type { IBootstrapService } from '@moonshot-ai/agent-core-v2/app/bootstrap/bootstrap';
import type {
ConfigDiagnostic,
ConfigInspectValue,
ConfigTarget,
} from '@moonshot-ai/agent-core-v2/app/config/config';
import type {
CapabilityInstallProgress,
CapabilityStatus,
CapabilityStep,
} from '@moonshot-ai/agent-core-v2/app/capability/types';
import type { ExperimentalFeatureState } from '@moonshot-ai/agent-core-v2/app/flag/flag';
import type {
FileMeta,
SaveOptions,
} from '@moonshot-ai/agent-core-v2/app/file/fileService';
import type {
FsBrowseResponse,
FsHomeResponse,
} from '@moonshot-ai/agent-core-v2/app/hostFolderBrowser/hostFolderBrowser';
import type { ModelRecord } from '@moonshot-ai/agent-core-v2/llm-adapter/model/model';
import type { IModelCatalog } from '@moonshot-ai/agent-core-v2/llm-adapter/model/catalog';
import type { IProviderDiscoveryService } from '@moonshot-ai/agent-core-v2/app/kosongConfig/discovery';
import type {
GetPluginInfoInput,
InstallPluginInput,
RemovePluginInput,
SetPluginEnabledInput,
SetPluginMcpServerEnabledInput,
} from '@moonshot-ai/agent-core-v2/app/plugin/plugin';
import type {
PluginCommandDef,
PluginDiagnostic,
PluginGithubMetadata,
PluginInfo,
PluginManifest,
PluginMcpServerInfo,
PluginSummary,
PluginUpdateStatus,
ReloadSummary,
} from '@moonshot-ai/agent-core-v2/app/plugin/types';
import type { ProviderConfig } from '@moonshot-ai/agent-core-v2/llm-adapter/provider/provider';
import type {
SessionListQuery,
SessionSummary,
} from '@moonshot-ai/agent-core-v2/app/sessionIndex/sessionIndex';
import type {
Workspace,
WorkspaceUpdate,
} from '@moonshot-ai/agent-core-v2/app/workspace/workspace';
// Test-only: the v1 wire event types now live in agent-core-v2; importing
// them here (never in `src/`) strengthens parity for the agent event stream.
import type { ToolResultEvent } from '@moonshot-ai/agent-core-v2/events';
import type {
CompactionBlockedEvent,
CompactionCancelledEvent,
CompactionCompletedEvent,
CompactionStartedEvent,
} from '@moonshot-ai/agent-core-v2/agent/fullCompaction/compactionOps';
import type {
AssistantDeltaEvent,
ThinkingDeltaEvent,
TurnStartedEvent,
} from '@moonshot-ai/agent-core-v2/agent/loop/turnEvents';
import type { TurnEndedEvent } from '@moonshot-ai/agent-core-v2/agent/loop/turnOps';
import type {
PromptAbortedEvent,
PromptCompletedEvent,
} from '@moonshot-ai/agent-core-v2/agent/prompt/promptEvents';
import type { TaskInfo } from '@moonshot-ai/agent-core-v2/agent/task/types';
import type {
ToolCallDeltaEvent,
ToolCallStartedEvent,
ToolProgressEvent,
} from '@moonshot-ai/agent-core-v2/agent/toolExecutor/toolExecutorEvents';
import type { WarningEvent } from '@moonshot-ai/agent-core-v2/errors';
import { sessionActivityStateSchema } from '../src/contract/session/activity.js';
import {
agentCommandInfoSchema,
agentContextDataSchema,
agentTaskInfoSchema,
activateSkillPayloadSchema,
cancelPayloadSchema,
cancelPlanPayloadSchema,
cancelShellCommandPayloadSchema,
emptyPayloadSchema,
getTaskOutputPayloadSchema,
getTasksPayloadSchema,
planDataSchema,
promptLaunchResultSchema,
promptPartSchema,
promptPayloadSchema,
promptSkillActivationSchema,
promptWithSkillsPayloadSchema,
promptWithSkillsResultSchema,
runCommandPayloadSchema,
runShellCommandPayloadSchema,
runtimeBindingSchema,
setModelPayloadSchema,
setModelResultSchema,
setPermissionPayloadSchema,
shellCommandResultSchema,
steerPayloadSchema,
stopTaskPayloadSchema,
tokenUsageSchema,
usageStatusSchema,
} from '../src/contract/agent/schemas.js';
import {
assistantDeltaEventSchema,
compactionBlockedEventSchema,
compactionCancelledEventSchema,
compactionCompletedEventSchema,
compactionStartedEventSchema,
promptAbortedEventSchema,
promptCompletedEventSchema,
thinkingDeltaEventSchema,
toolCallDeltaEventSchema,
toolCallStartedEventSchema,
toolProgressEventSchema,
toolResultEventSchema,
turnEndedEventSchema,
turnStartedEventSchema,
warningEventSchema,
} from '../src/contract/agent/events.js';
import {
approvalRequestSchema,
approvalResponseSchema,
} from '../src/contract/session/approval.js';
import {
fullCompactionInputSchema,
mcpServerEntrySchema,
} from '../src/contract/agent/services.js';
import {
createChildSessionOptionsSchema,
createSessionOptionsSchema,
forkSessionOptionsSchema,
handleWireSchema,
resumeSessionOptionsSchema,
} from '../src/contract/session/lifecycle.js';
import {
interactionResolutionSchema,
interactionSchema,
} from '../src/contract/session/interaction.js';
import {
agentMetaSchema,
sessionMetaPatchSchema,
sessionMetaSchema,
sessionMetadataChangedEventSchema,
} from '../src/contract/session/metadata.js';
import {
questionAnswersSchema,
questionItemSchema,
questionOptionSchema,
questionRequestSchema,
questionResponseSchema,
questionResultSchema,
} from '../src/contract/session/question.js';
import { skillSummarySchema } from '../src/contract/session/skills.js';
import { sessionTitleContract } from '../src/contract/session/title.js';
import {
authStatusSchema,
oAuthFlowSnapshotSchema,
oAuthFlowStartSchema,
oAuthLoginCancelResponseSchema,
oAuthLogoutResponseSchema,
refreshOAuthProviderModelsResponseSchema,
} from '../src/contract/global/auth.js';
import {
configDiagnosticSchema,
configInspectValueSchema,
configTargetSchema,
} from '../src/contract/global/config.js';
import {
capabilityInstallProgressSchema,
capabilityStatusSchema,
capabilityStepSchema,
} from '../src/contract/global/capabilities.js';
import {
modelCatalogItemSchema,
providerCatalogItemSchema,
setDefaultModelResponseSchema,
} from '../src/contract/global/catalog.js';
import {
refreshProviderModelsOptionsSchema,
refreshProviderModelsResponseSchema,
} from '../src/contract/global/providerDiscovery.js';
import { experimentalFeatureStateSchema } from '../src/contract/global/flags.js';
import {
fileMetaSchema,
fileSaveOptionsSchema,
} from '../src/contract/global/files.js';
import {
fsBrowseResponseSchema,
fsHomeResponseSchema,
} from '../src/contract/global/hostFs.js';
import { modelConfigSchema } from '../src/contract/global/models.js';
import {
globalMcpServerConfigSchema,
mcpAuthStatusQuerySchema,
mcpManagedServerSchema,
mcpRegistryPluginOriginSchema,
mcpRegistryQuerySchema,
mcpServerAuthBeginResultSchema,
mcpServerAuthFlowHandleSchema,
mcpServerAuthStateSchema,
mcpServerAuthStatusSchema,
mcpServerConfigDataSchema,
mcpServerInspectionSchema,
mcpServerLocatorSchema,
mcpServerSourceSchema,
mcpServerTestResultSchema,
mcpServerTestTargetSchema,
} from '../src/contract/global/mcpManagement.js';
import {
getPluginInfoInputSchema,
installPluginInputSchema,
pluginCommandDefSchema,
pluginDiagnosticSchema,
pluginGithubMetadataSchema,
pluginInfoSchema,
pluginManifestSchema,
pluginMcpServerInfoSchema,
pluginSummarySchema,
pluginUpdateStatusSchema,
reloadSummarySchema,
removePluginInputSchema,
setPluginEnabledInputSchema,
setPluginMcpServerEnabledInputSchema,
} from '../src/contract/global/plugins.js';
import { providerConfigSchema } from '../src/contract/global/providers.js';
import {
sessionListQuerySchema,
sessionSummarySchema,
} from '../src/contract/global/sessions.js';
import {
workspaceSchema,
workspaceUpdateSchema,
} from '../src/contract/global/workspaces.js';
import type { AssertWire, MutableDeep } from './helpers/typeAssert.js';
import type { AgentFacade } from '../src/core/facade/agent.js';
/** One-directional: the engine type must be assignable TO the schema's infer. */
type AssertEngineToWire<TSchema extends z.ZodType, TEngine> = [MutableDeep<TEngine>] extends [
z.infer<TSchema>,
]
? true
: never;
/** One-directional: the schema's infer must be assignable TO the engine type. */
type AssertWireToEngine<TSchema extends z.ZodType, TEngine> = [z.infer<TSchema>] extends [
MutableDeep<TEngine>,
]
? true
: never;
// Wire shapes, derived from the engine interfaces.
type OAuthFlowStart = Awaited<ReturnType<IOAuthService['startLogin']>>;
type OAuthFlowSnapshot = NonNullable<ReturnType<IOAuthService['getFlow']>>;
type OAuthLoginCancelResponse = Awaited<ReturnType<IOAuthService['cancelLogin']>>;
type OAuthLogoutResponse = Awaited<ReturnType<IOAuthService['logout']>>;
type RefreshOAuthProviderModelsResponse = Awaited<
ReturnType<IOAuthService['refreshOAuthProviderModels']>
>;
/** String-enum value union (`'user' | 'memory'`). */
type ConfigTargetValues = `${ConfigTarget}`;
// sessions.ts
const _sessionSummary: AssertWire<typeof sessionSummarySchema, SessionSummary> = true;
const _sessionListQuery: AssertWire<typeof sessionListQuerySchema, SessionListQuery> = true;
// workspaces.ts
const _workspace: AssertWire<typeof workspaceSchema, Workspace> = true;
const _workspaceUpdate: AssertWire<typeof workspaceUpdateSchema, WorkspaceUpdate> = true;
// config.ts
// One-directional: the engine declares the `ConfigInspectValue` keys as
// required with `| undefined` values, while the wire schema marks them
// `.optional()`; optional β required is not assignable, so only the
// engine β wire direction holds.
const _configInspectValue: AssertEngineToWire<typeof configInspectValueSchema, ConfigInspectValue> =
true;
const _configDiagnostic: AssertWire<typeof configDiagnosticSchema, ConfigDiagnostic> = true;
const _configTarget: AssertWire<typeof configTargetSchema, ConfigTargetValues> = true;
// capabilities.ts
const _capabilityStep: AssertWire<typeof capabilityStepSchema, CapabilityStep> = true;
const _capabilityInstallProgress: AssertWire<
typeof capabilityInstallProgressSchema,
CapabilityInstallProgress
> = true;
const _capabilityStatus: AssertWire<typeof capabilityStatusSchema, CapabilityStatus> = true;
// providers.ts
const _providerConfig: AssertWire<typeof providerConfigSchema, ProviderConfig> = true;
// auth.ts
const _oAuthFlowStart: AssertWire<typeof oAuthFlowStartSchema, OAuthFlowStart> = true;
const _oAuthFlowSnapshot: AssertWire<typeof oAuthFlowSnapshotSchema, OAuthFlowSnapshot> = true;
const _oAuthLoginCancelResponse: AssertWire<
typeof oAuthLoginCancelResponseSchema,
OAuthLoginCancelResponse
> = true;
const _oAuthLogoutResponse: AssertWire<typeof oAuthLogoutResponseSchema, OAuthLogoutResponse> =
true;
const _authStatus: AssertWire<typeof authStatusSchema, AuthStatus> = true;
const _refreshOAuthProviderModelsResponse: AssertWire<
typeof refreshOAuthProviderModelsResponseSchema,
RefreshOAuthProviderModelsResponse
> = true;
// flags.ts
const _experimentalFeatureState: AssertWire<
typeof experimentalFeatureStateSchema,
ExperimentalFeatureState
> = true;
// hostFs.ts
const _fsBrowseResponse: AssertWire<typeof fsBrowseResponseSchema, FsBrowseResponse> = true;
const _fsHomeResponse: AssertWire<typeof fsHomeResponseSchema, FsHomeResponse> = true;
// files.ts (`fileGetResultSchema` has no engine counterpart β the wire
// adaptation replaces `GetResult.stream` with base64 `data`).
const _fileMeta: AssertWire<typeof fileMetaSchema, FileMeta> = true;
const _fileSaveOptions: AssertWire<typeof fileSaveOptionsSchema, SaveOptions> = true;
// catalog.ts / providerDiscovery.ts β protocol wire shapes derived through the
// catalog and discovery service interfaces.
type ModelCatalogItem = Awaited<ReturnType<IModelCatalog['listModels']>>[number];
type ProviderCatalogItem = Awaited<ReturnType<IModelCatalog['listProviders']>>[number];
type SetDefaultModelResponse = Awaited<ReturnType<IModelCatalog['setDefaultModel']>>;
type RefreshProviderModelsOptions = NonNullable<
Parameters<IProviderDiscoveryService['refreshProviderModels']>[0]
>;
type RefreshProviderModelsResponse = Awaited<
ReturnType<IProviderDiscoveryService['refreshProviderModels']>
>;
const _modelCatalogItem: AssertWire<typeof modelCatalogItemSchema, ModelCatalogItem> = true;
const _providerCatalogItem: AssertWire<typeof providerCatalogItemSchema, ProviderCatalogItem> =
true;
const _setDefaultModelResponse: AssertWire<
typeof setDefaultModelResponseSchema,
SetDefaultModelResponse
> = true;
const _refreshProviderModelsOptions: AssertWire<
typeof refreshProviderModelsOptionsSchema,
RefreshProviderModelsOptions
> = true;
const _refreshProviderModelsResponse: AssertWire<
typeof refreshProviderModelsResponseSchema,
RefreshProviderModelsResponse
> = true;
// models.ts
const _modelConfig: AssertWire<typeof modelConfigSchema, ModelRecord> = true;
// plugins.ts
const _pluginSummary: AssertWire<typeof pluginSummarySchema, PluginSummary> = true;
const _pluginInfo: AssertWire<typeof pluginInfoSchema, PluginInfo> = true;
const _pluginManifest: AssertWire<typeof pluginManifestSchema, PluginManifest> = true;
const _pluginMcpServerInfo: AssertWire<typeof pluginMcpServerInfoSchema, PluginMcpServerInfo> =
true;
const _pluginDiagnostic: AssertWire<typeof pluginDiagnosticSchema, PluginDiagnostic> = true;
const _pluginGithubMetadata: AssertWire<typeof pluginGithubMetadataSchema, PluginGithubMetadata> =
true;
const _reloadSummary: AssertWire<typeof reloadSummarySchema, ReloadSummary> = true;
const _pluginUpdateStatus: AssertWire<typeof pluginUpdateStatusSchema, PluginUpdateStatus> = true;
const _pluginCommandDef: AssertWire<typeof pluginCommandDefSchema, PluginCommandDef> = true;
const _installPluginInput: AssertWire<typeof installPluginInputSchema, InstallPluginInput> = true;
const _setPluginEnabledInput: AssertWire<
typeof setPluginEnabledInputSchema,
SetPluginEnabledInput
> = true;
const _setPluginMcpServerEnabledInput: AssertWire<
typeof setPluginMcpServerEnabledInputSchema,
SetPluginMcpServerEnabledInput
> = true;
const _removePluginInput: AssertWire<typeof removePluginInputSchema, RemovePluginInput> = true;
const _getPluginInfoInput: AssertWire<typeof getPluginInfoInputSchema, GetPluginInfoInput> = true;
// global/mcpManagement.ts β the `McpServerConfig | McpServerConfigView` union
// a managed server's `config` carries (full for mutable entries, redacted for
// read-only ones) is mirrored by one schema covering both shapes; the
// inspection's `config` is always the redacted view, and both assignability
// directions hold against either engine type.
const _mcpServerSource: AssertWire<typeof mcpServerSourceSchema, McpServerSource> = true;
const _mcpRegistryPluginOrigin: AssertWire<
typeof mcpRegistryPluginOriginSchema,
McpRegistryPluginOrigin
> = true;
const _mcpRegistryQuery: AssertWire<typeof mcpRegistryQuerySchema, McpRegistryQuery> = true;
const _mcpAuthStatusQuery: AssertWire<typeof mcpAuthStatusQuerySchema, McpAuthStatusQuery> = true;
const _globalMcpServerConfig: AssertWire<
typeof globalMcpServerConfigSchema,
GlobalMcpServerConfig
> = true;
const _mcpServerConfigData: AssertWire<
typeof mcpServerConfigDataSchema,
McpServerConfig | McpServerConfigView
> = true;
const _mcpServerConfigViewData: AssertWire<
typeof mcpServerConfigDataSchema,
McpServerConfigView
> = true;
const _mcpManagedServer: AssertWire<typeof mcpManagedServerSchema, McpManagedServer> = true;
const _mcpServerTestTarget: AssertWire<typeof mcpServerTestTargetSchema, McpServerTestTarget> =
true;
const _mcpServerTestResult: AssertWire<typeof mcpServerTestResultSchema, McpServerTestResult> =
true;
const _mcpServerLocator: AssertWire<typeof mcpServerLocatorSchema, McpServerLocator> = true;
const _mcpServerAuthState: AssertWire<typeof mcpServerAuthStateSchema, McpServerAuthState> = true;
const _mcpServerInspection: AssertWire<typeof mcpServerInspectionSchema, McpServerInspection> =
true;
const _mcpServerAuthStatus: AssertWire<typeof mcpServerAuthStatusSchema, McpServerAuthStatus> =
true;
const _mcpServerAuthBeginResult: AssertWire<
typeof mcpServerAuthBeginResultSchema,
McpServerAuthBeginResult
> = true;
const _mcpServerAuthFlowHandle: AssertWire<
typeof mcpServerAuthFlowHandleSchema,
McpServerAuthFlowHandle
> = true;
// env.ts has no named schemas; `platform` narrows to `NodeJS.Platform` in the
// engine β assert the bootstrap properties are all strings instead. The
// object-typed `clientIdentity` is intentionally not in this list.
type _bootstrapStringProps = AssertStringProps<
Pick<
IBootstrapService,
| 'platform'
| 'arch'
| 'cwd'
| 'osHomeDir'
| 'homeDir'
| 'configPath'
| 'sessionsDir'
| 'blobsDir'
| 'storeDir'
| 'cacheDir'
| 'logsDir'
>
>;
type AssertStringProps<T> = T extends Record<string, string> ? true : never;
const _envProps: _bootstrapStringProps = true;
// ββ session scope βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
// session/metadata.ts
const _sessionMeta: AssertWire<typeof sessionMetaSchema, SessionMeta> = true;
const _agentMeta: AssertWire<typeof agentMetaSchema, AgentMeta> = true;
const _sessionMetaPatch: AssertWire<typeof sessionMetaPatchSchema, SessionMetaPatch> = true;
const _sessionMetadataChangedEvent: AssertWire<
typeof sessionMetadataChangedEventSchema,
SessionMetadataChangedEvent
> = true;
// session/lifecycle.ts
const _createSessionOptions: AssertWire<typeof createSessionOptionsSchema, CreateSessionOptions> =
true;
const _forkSessionOptions: AssertWire<typeof forkSessionOptionsSchema, ForkSessionOptions> = true;
const _resumeSessionOptions: AssertWire<typeof resumeSessionOptionsSchema, ResumeSessionOptions> =
true;
const _createChildSessionOptions: AssertWire<
typeof createChildSessionOptionsSchema,
CreateChildSessionOptions
> = true;
// One-directional: the wire handle is `z.looseObject` β the in-process
// `ISessionScopeHandle` carries an `accessor` and `dispose()` that JSON
// drops, so only the engine β wire direction holds.
const _handleWire: AssertEngineToWire<typeof handleWireSchema, ISessionScopeHandle> = true;
// session/interaction.ts
const _interaction: AssertWire<typeof interactionSchema, Interaction> = true;
const _interactionResolution: AssertWire<
typeof interactionResolutionSchema,
InteractionResolution
> = true;
// session/approval.ts
// One-directional: `display` is the protocol `ToolInputDisplay` union (huge)
// and crosses the wire as `unknown`; the wire schema cannot be assignable
// back to the engine type.
const _approvalRequest: AssertEngineToWire<typeof approvalRequestSchema, ApprovalRequest> = true;
const _approvalResponse: AssertWire<typeof approvalResponseSchema, ApprovalResponse> = true;
// session/question.ts
const _questionRequest: AssertWire<typeof questionRequestSchema, QuestionRequest> = true;
const _questionItem: AssertWire<typeof questionItemSchema, QuestionItem> = true;
const _questionOption: AssertWire<typeof questionOptionSchema, QuestionOption> = true;
const _questionAnswers: AssertWire<typeof questionAnswersSchema, QuestionAnswers> = true;
const _questionResponse: AssertWire<typeof questionResponseSchema, QuestionResponse> = true;
const _questionResult: AssertWire<typeof questionResultSchema, QuestionResult> = true;
// session/skills.ts
const _skillSummary: AssertWire<typeof skillSummarySchema, SkillSummary> = true;
// session/title.ts
const _generateTitleOutput: AssertWire<
(typeof sessionTitleContract)['generateTitle']['output'],
Awaited<ReturnType<ISessionTitleService['generateTitle']>>
> = true;
// session/activity.ts
const _sessionActivityState: AssertWire<typeof sessionActivityStateSchema, SessionActivityState> =
true;
// ββ agent scope (services.ts / schemas.ts) ββββββββββββββββββββββββββββββββββ
// Payload/result types are derived from the domain service interfaces the
// facade calls, so the assertions track the exact methods the contract
// mirrors; facade-only payload shapes (cancel / setPermission / plan / task /
// command) derive from the `AgentFacade` input types.
type ActivateSkillPayload = Parameters<IAgentSkillService['activate']>[0];
type PromptWithSkillsPayload = Parameters<IAgentSkillService['promptWithSkills']>[0];
type PromptSkillActivation = PromptWithSkillsPayload['skills'][number];
type AgentCommandInfo = ReturnType<IAgentCommandService['list']>[number];
type RuntimeBinding = ReturnType<IAgentRuntimeBindingService['get']>;
type RunShellCommandPayload = Parameters<IAgentShellCommandService['run']>[0];
type ShellCommandResult = Awaited<ReturnType<IAgentShellCommandService['run']>>;
type SetModelResult = Awaited<ReturnType<IAgentProfileService['setModel']>>;
type TokenUsage = NonNullable<UsageStatus['total']>;
type PromptPart = Extract<ContentPart, { type: 'text' | 'image_url' | 'video_url' }>;
type EmptyPayload = {};
type CancelPayload = NonNullable<Parameters<AgentFacade['cancel']>[0]>;
type SetPermissionPayload = { mode: PermissionMode };
type RunCommandPayload = Parameters<AgentFacade['runCommand']>[0];
type CancelShellCommandPayload = Parameters<AgentFacade['cancelShellCommand']>[0];
type SetModelPayload = { model: string };
type CancelPlanPayload = NonNullable<Parameters<AgentFacade['cancelPlan']>[0]>;
type GetTasksPayload = NonNullable<Parameters<AgentFacade['getTasks']>[0]>;
type StopTaskPayload = Parameters<AgentFacade['stopTask']>[0];
type GetTaskOutputPayload = Parameters<AgentFacade['getTaskOutput']>[0];
const _emptyPayload: AssertWire<typeof emptyPayloadSchema, EmptyPayload> = true;
const _promptPart: AssertWire<typeof promptPartSchema, PromptPart> = true;
// One-directional (wire β engine): the engine's `PromptPayload.input` accepts
// the full `ContentPart` union (also think/audio parts); the wire mirrors the
// `PromptPart` subset clients may send, so the reverse direction fails.
const _promptPayload: AssertWireToEngine<typeof promptPayloadSchema, PromptPayload> = true;
const _promptSkillActivation: AssertWire<
typeof promptSkillActivationSchema,
PromptSkillActivation
> = true;
// Same one-directional rule as `promptPayload`: the engine's `input` accepts
// the full `ContentPart` union; the wire mirrors the `PromptPart` subset.
const _promptWithSkillsPayload: AssertWireToEngine<
typeof promptWithSkillsPayloadSchema,
PromptWithSkillsPayload
> = true;
const _steerPayload: AssertWireToEngine<typeof steerPayloadSchema, SteerPayload> = true;
const _activateSkillPayload: AssertWire<typeof activateSkillPayloadSchema, ActivateSkillPayload> =
true;
const _promptLaunchResult: AssertWire<typeof promptLaunchResultSchema, PromptLaunchResult> = true;
type PromptWithSkillsResult = Awaited<ReturnType<IAgentSkillService['promptWithSkills']>>;
const _promptWithSkillsResult: AssertWire<
typeof promptWithSkillsResultSchema,
PromptWithSkillsResult
> = true;
const _cancelPayload: AssertWire<typeof cancelPayloadSchema, CancelPayload> = true;
const _runShellCommandPayload: AssertWire<
typeof runShellCommandPayloadSchema,
RunShellCommandPayload
> = true;
const _shellCommandResult: AssertWire<typeof shellCommandResultSchema, ShellCommandResult> = true;
const _cancelShellCommandPayload: AssertWire<
typeof cancelShellCommandPayloadSchema,
CancelShellCommandPayload
> = true;
const _setModelPayload: AssertWire<typeof setModelPayloadSchema, SetModelPayload> = true;
const _setModelResult: AssertWire<typeof setModelResultSchema, SetModelResult> = true;
const _setPermissionPayload: AssertWire<typeof setPermissionPayloadSchema, SetPermissionPayload> =
true;
const _tokenUsage: AssertWire<typeof tokenUsageSchema, TokenUsage> = true;
const _usageStatus: AssertWire<typeof usageStatusSchema, UsageStatus> = true;
// One-directional: `history` entries are full `ContextMessage`s (deep
// `Message`/`Tool`/`PromptOrigin` unions) mirrored as `unknown`.
const _agentContextData: AssertEngineToWire<typeof agentContextDataSchema, AgentContextData> = true;
const _agentCommandInfo: AssertWire<typeof agentCommandInfoSchema, AgentCommandInfo> = true;
const _runtimeBinding: AssertWire<typeof runtimeBindingSchema, RuntimeBinding> = true;
const _runCommandPayload: AssertWire<typeof runCommandPayloadSchema, RunCommandPayload> = true;
const _planData: AssertWire<typeof planDataSchema, PlanData> = true;
const _cancelPlanPayload: AssertWire<typeof cancelPlanPayloadSchema, CancelPlanPayload> = true;
const _getTasksPayload: AssertWire<typeof getTasksPayloadSchema, GetTasksPayload> = true;
// The wire task union mirrors the protocol `TaskInfo`; the engine's
// declaration-merged `AgentTaskInfo` is structurally identical but depends on
// tool-module augmentation, so parity is pinned to the protocol type.
const _agentTaskInfo: AssertWire<typeof agentTaskInfoSchema, TaskInfo> = true;
const _stopTaskPayload: AssertWire<typeof stopTaskPayloadSchema, StopTaskPayload> = true;
const _getTaskOutputPayload: AssertWire<typeof getTaskOutputPayloadSchema, GetTaskOutputPayload> =
true;
// agent/services.ts (mcp / fullCompaction)
const _mcpServerEntry: AssertWire<typeof mcpServerEntrySchema, McpServerEntry> = true;
const _fullCompactionInput: AssertWire<typeof fullCompactionInputSchema, FullCompactionInput> =
true;
// ββ agent scope (events.ts) βββββββββββββββββββββββββββββββββββββββββββββββββ
// Parity against the protocol event types (the stream carries flat
// `{ type, ... }` events; schemas keep the `type` literal). One-directional
// where a field is mirrored as `unknown`.
const _turnStartedEvent: AssertEngineToWire<typeof turnStartedEventSchema, TurnStartedEvent> = true;
const _turnEndedEvent: AssertEngineToWire<typeof turnEndedEventSchema, TurnEndedEvent> = true;
const _assistantDeltaEvent: AssertWire<typeof assistantDeltaEventSchema, AssistantDeltaEvent> =
true;
const _thinkingDeltaEvent: AssertWire<typeof thinkingDeltaEventSchema, ThinkingDeltaEvent> = true;
const _toolCallStartedEvent: AssertEngineToWire<
typeof toolCallStartedEventSchema,
ToolCallStartedEvent
> = true;
const _toolCallDeltaEvent: AssertWire<typeof toolCallDeltaEventSchema, ToolCallDeltaEvent> = true;
const _toolProgressEvent: AssertWire<typeof toolProgressEventSchema, ToolProgressEvent> = true;
const _toolResultEvent: AssertWire<typeof toolResultEventSchema, ToolResultEvent> = true;
const _promptCompletedEvent: AssertWire<typeof promptCompletedEventSchema, PromptCompletedEvent> =
true;
const _promptAbortedEvent: AssertWire<typeof promptAbortedEventSchema, PromptAbortedEvent> = true;
const _compactionStartedEvent: AssertWire<
typeof compactionStartedEventSchema,
CompactionStartedEvent
> = true;
const _compactionBlockedEvent: AssertWire<
typeof compactionBlockedEventSchema,
CompactionBlockedEvent
> = true;
const _compactionCancelledEvent: AssertWire<
typeof compactionCancelledEventSchema,
CompactionCancelledEvent
> = true;
const _compactionCompletedEvent: AssertWire<
typeof compactionCompletedEventSchema,
CompactionCompletedEvent
> = true;
const _warningEvent: AssertWire<typeof warningEventSchema, WarningEvent> = true;
// No parity assertions for `errorEventSchema`, `permissionApproval*Schema`,
// and `agentStatusUpdatedEventSchema`: they are deliberately `z.looseObject`s
// (index signature breaks both-ways assignability) β `permission.approval.*`
// is not part of the protocol event union at all.
|