-
-
Notifications
You must be signed in to change notification settings - Fork 315
refactor(mcp): project system family output schemas from their owning module #3014
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -1,7 +1,9 @@ | ||||||||
| import { FOLD_FLAGS } from '@agent-device/command-registry/flag-groups'; | ||||||||
| import type { CommandResultMap } from '@agent-device/command-registry/command-result'; | ||||||||
| import type { ClipboardCommandOptions } from '@agent-device/contracts/client'; | ||||||||
| import { | ||||||||
| type FoldKeyframe, | ||||||||
| FOLD_SCREEN_COORDINATE_SPACE, | ||||||||
| MAX_FOLD_DURATION_MS, | ||||||||
| MAX_FOLD_KEYFRAMES, | ||||||||
| parseFoldInput, | ||||||||
|
|
@@ -18,6 +20,8 @@ import { | |||||||
| parseTvRemoteButton, | ||||||||
| tvRemoteDurationMode, | ||||||||
| } from '@agent-device/contracts/tv-remote'; | ||||||||
| import { APPLE_APPLICATION_STATES } from '@agent-device/kernel/snapshot'; | ||||||||
| import { SESSION_SURFACES } from '@agent-device/contracts/session'; | ||||||||
| import { AppError } from '@agent-device/kernel/errors'; | ||||||||
| import type { CommandSchemaOverride } from '@agent-device/command-registry/command-schema'; | ||||||||
| import { | ||||||||
|
|
@@ -28,13 +32,20 @@ import { | |||||||
| requiredDaemonString, | ||||||||
| } from '../cli-grammar/common.ts'; | ||||||||
| import type { CliReader, DaemonWriter } from '../cli-grammar/types.ts'; | ||||||||
| import type { JsonSchema } from '../command-contract.ts'; | ||||||||
| import { | ||||||||
| enumField, | ||||||||
| integerField, | ||||||||
| requiredField, | ||||||||
| stringField, | ||||||||
| jsonSchemaField, | ||||||||
| readFieldInput, | ||||||||
| booleanSchema, | ||||||||
| constSchema, | ||||||||
| enumSchema, | ||||||||
| numberSchema, | ||||||||
| objectSchema, | ||||||||
| stringSchema, | ||||||||
| } from '../command-input.ts'; | ||||||||
| import { compactRecord } from '../input-readers.ts'; | ||||||||
| import { | ||||||||
|
|
@@ -64,6 +75,154 @@ const TV_REMOTE_LONGPRESS_PRESET_MS = 500; | |||||||
| const CLIPBOARD_ACTION_VALUES = ['read', 'write'] as const; | ||||||||
| const KEYBOARD_METADATA_ACTION_VALUES = ['status', 'dismiss', 'enter', 'return'] as const; | ||||||||
|
|
||||||||
| /** | ||||||||
| * This family's advertised MCP `outputSchema`s, keyed by daemon command name and projected into | ||||||||
| * the command map by `src/mcp/command-output-schemas.ts`. Non-strict like every other entry: no | ||||||||
| * `additionalProperties: false`, so additive response fields such as `settle`/`cost` keep | ||||||||
| * validating. `back`'s settle observation is grafted separately by the trait derivation pass. | ||||||||
| */ | ||||||||
| export const SYSTEM_COMMAND_OUTPUT_SCHEMAS = { | ||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P3: The change is described as exporting a "frozen" map, but Prompt for AI agents |
||||||||
| back: objectSchema( | ||||||||
| { | ||||||||
| action: constSchema('back'), | ||||||||
| mode: enumSchema(BACK_MODES), | ||||||||
| message: stringSchema(), | ||||||||
| }, | ||||||||
| ['action', 'mode', 'message'], | ||||||||
| ), | ||||||||
| home: objectSchema({ action: constSchema('home'), message: stringSchema() }, [ | ||||||||
| 'action', | ||||||||
| 'message', | ||||||||
| ]), | ||||||||
| orientation: objectSchema( | ||||||||
| { | ||||||||
| action: constSchema('orientation'), | ||||||||
| orientation: enumSchema(DEVICE_ROTATIONS), | ||||||||
| message: stringSchema(), | ||||||||
| confirmed: booleanSchema(), | ||||||||
| warning: stringSchema(), | ||||||||
| }, | ||||||||
| ['action', 'orientation', 'message'], | ||||||||
| ), | ||||||||
| 'app-switcher': objectSchema({ action: constSchema('app-switcher'), message: stringSchema() }, [ | ||||||||
| 'action', | ||||||||
| 'message', | ||||||||
| ]), | ||||||||
| fold: objectSchema( | ||||||||
| { | ||||||||
| action: constSchema('fold'), | ||||||||
| pose: enumSchema(FOLD_POSES), | ||||||||
| hingeAngleDegrees: numberSchema('Hinge angle CoreDevice read back after the pose settled.'), | ||||||||
| screen: objectSchema( | ||||||||
| { | ||||||||
| display: stringSchema('CoreDevice name of the panel the device now lights.'), | ||||||||
| coordinateSpace: constSchema(FOLD_SCREEN_COORDINATE_SPACE), | ||||||||
| widthPt: numberSchema( | ||||||||
| 'Panel width in native panel points (pixels divided by point scale), NOT snapshot coordinates; take a fresh snapshot to place a tap.', | ||||||||
| ), | ||||||||
| heightPt: numberSchema( | ||||||||
| 'Panel height in native panel points (pixels divided by point scale), NOT snapshot coordinates; take a fresh snapshot to place a tap.', | ||||||||
| ), | ||||||||
| }, | ||||||||
| ['display', 'coordinateSpace', 'widthPt', 'heightPt'], | ||||||||
| ), | ||||||||
| message: stringSchema(), | ||||||||
| }, | ||||||||
| ['action', 'pose', 'hingeAngleDegrees', 'message'], | ||||||||
| ), | ||||||||
| 'action-button': objectSchema({ action: constSchema('action-button'), message: stringSchema() }, [ | ||||||||
| 'action', | ||||||||
| 'message', | ||||||||
| ]), | ||||||||
| 'tv-remote': objectSchema( | ||||||||
| { | ||||||||
| action: constSchema('tv-remote'), | ||||||||
| button: enumSchema(TV_REMOTE_BUTTONS), | ||||||||
| durationMs: numberSchema(), | ||||||||
| message: stringSchema(), | ||||||||
| }, | ||||||||
| ['action', 'button', 'message'], | ||||||||
| ), | ||||||||
| // packages/contracts/src/clipboard.ts — discriminated union on `action`. | ||||||||
| clipboard: { | ||||||||
| type: 'object', | ||||||||
| oneOf: [ | ||||||||
| objectSchema({ action: constSchema('read'), text: stringSchema() }, ['action', 'text']), | ||||||||
| objectSchema( | ||||||||
| { action: constSchema('write'), textLength: numberSchema(), message: stringSchema() }, | ||||||||
| ['action', 'textLength', 'message'], | ||||||||
| ), | ||||||||
| ], | ||||||||
| }, | ||||||||
| // packages/contracts/src/app-state.ts — discriminated union on `platform`. | ||||||||
| appstate: { | ||||||||
| type: 'object', | ||||||||
| oneOf: [ | ||||||||
| objectSchema( | ||||||||
| { | ||||||||
| platform: enumSchema(['ios', 'macos']), | ||||||||
| appName: stringSchema(), | ||||||||
| appBundleId: stringSchema(), | ||||||||
| source: enumSchema( | ||||||||
| ['session', 'runner'], | ||||||||
| 'runner when a live runner read the session app state; session when the record alone answered.', | ||||||||
| ), | ||||||||
| state: enumSchema( | ||||||||
| APPLE_APPLICATION_STATES, | ||||||||
| 'The session app XCUIApplication state as a live runner reads it; absent with source session.', | ||||||||
| ), | ||||||||
| surface: enumSchema(SESSION_SURFACES), | ||||||||
| device_udid: stringSchema('iOS only — the session device UDID.'), | ||||||||
| ios_simulator_device_set: { | ||||||||
| type: ['string', 'null'], | ||||||||
| description: 'iOS only — the simulator set path, or null when unknown.', | ||||||||
| }, | ||||||||
| }, | ||||||||
| ['platform', 'appName', 'source', 'surface'], | ||||||||
| ), | ||||||||
| objectSchema( | ||||||||
| { | ||||||||
| platform: constSchema('android'), | ||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P1: The appstate schema rejects successful HarmonyOS responses. Use the same Prompt for AI agents
Suggested change
|
||||||||
| package: stringSchema(), | ||||||||
| activity: stringSchema(), | ||||||||
| }, | ||||||||
| ['platform', 'package', 'activity'], | ||||||||
| ), | ||||||||
| ], | ||||||||
| }, | ||||||||
| // packages/contracts/src/keyboard.ts — flat closed shape; `platform`/`action` always present. | ||||||||
| keyboard: objectSchema( | ||||||||
| { | ||||||||
| platform: enumSchema(['android', 'ios']), | ||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P1: The keyboard schema rejects HarmonyOS dismiss and enter results. Add Prompt for AI agents
Suggested change
|
||||||||
| action: enumSchema(['status', 'dismiss', 'enter']), | ||||||||
| visible: booleanSchema(), | ||||||||
| wasVisible: booleanSchema(), | ||||||||
| dismissed: booleanSchema(), | ||||||||
| attempts: numberSchema(), | ||||||||
| inputType: stringSchema(), | ||||||||
| type: enumSchema(['text', 'number', 'email', 'phone', 'password', 'datetime', 'unknown']), | ||||||||
| inputMethodPackage: stringSchema(), | ||||||||
| focusedPackage: stringSchema(), | ||||||||
| focusedResourceId: stringSchema(), | ||||||||
| inputOwner: enumSchema(['app', 'ime', 'unknown']), | ||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: The keyboard output schema omits the contract's Prompt for AI agents
Suggested change
|
||||||||
| message: stringSchema(), | ||||||||
| }, | ||||||||
| ['platform', 'action'], | ||||||||
| ), | ||||||||
| } satisfies Pick< | ||||||||
| Record<keyof CommandResultMap, JsonSchema>, | ||||||||
| | 'back' | ||||||||
| | 'home' | ||||||||
| | 'orientation' | ||||||||
| | 'app-switcher' | ||||||||
| | 'fold' | ||||||||
| | 'action-button' | ||||||||
| | 'tv-remote' | ||||||||
| | 'clipboard' | ||||||||
| | 'appstate' | ||||||||
| | 'keyboard' | ||||||||
| >; | ||||||||
|
|
||||||||
| const appStateCommandDescription = | ||||||||
| 'Show foreground app/activity (Android; iOS answers per command)'; | ||||||||
| const backCommandDescription = | ||||||||
|
|
||||||||
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P1: This removes
FOLD_SCREEN_COORDINATE_SPACEfrom the published@agent-device/contracts/fold-runtimesubpath, breaking existing consumers that import the value there. Preserve the compatibility re-export fromdevice-rotation.tswhile using the relocated constant internally.Prompt for AI agents