Skip to content

dan1510123/CopilotOffice

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

332 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Copilot Office 🏒

A 2D pixel-art RPG-style desktop game where you walk around a virtual office and interact with AI agents. Each NPC runs a real GitHub Copilot CLI session with full coding capabilities β€” plan tasks, debug code, and orchestrate multi-agent workflows from inside a game. You can even bring an agent online in a Microsoft Teams channel and drive it from your phone.

Copilot Office

Features

  • Pixel-art office environment β€” every sprite is procedurally generated in code; there are no external image assets
  • Real Copilot agents β€” each NPC runs an actual Copilot CLI session, rendered live in an xterm.js terminal
  • 3 active NPC agents by default, each with a distinct personality:
    • Gene (Generalist) β€” general-purpose coding, debugging, and research
    • Dan (Debugger) β€” bug investigation and root-cause analysis
    • Alice (Admin) β€” has direct access to edit this game's own source code (workingDir: '.')
  • 6 reserve agents β€” Azure (Cloud Wizard), Val (Validator), Rex (Deployer), Doc (Code Doctor), Scout (Ranger), and Penny (Accountant) have pre-generated sprites ready to seat at an empty desk
  • Arthur (the Architect) β€” hosts Meeting Mode and appears in fleet v-team offices (can be toggled into the default office in config)
  • Teams remote agents β€” bring any agent online in a Microsoft Teams channel thread; anyone can reply in-thread to drive the agent's terminal session and get answers posted back (feature-flagged)
  • Multi-office management β€” switch between projects with independent agent state and working directories per office
  • Meeting Mode β€” a private meeting room where Arthur decomposes a complex request into a structured, reviewable plan
  • Fleet execution β€” approved plans spin up parallel agent sessions in a dedicated v-team office
  • Real-time status badges β€” agent states (slacking β†’ starting β†’ ready ↔ waiting/thinking) with animated indicators
  • Toast & OS notifications β€” configurable per-event notifications for agent activity
  • Session persistence β€” offices, seated agents, and terminal sessions survive restarts
  • Player & sprite customization β€” customize your character's appearance and colors
  • Mini-games β€” a built-in Galaxian arcade game (Pong and Basketball are also included behind feature flags)
  • Hot reload development mode with file watching

Tech Stack

  • Phaser 3 β€” 2D game framework (the sole renderer)
  • Electron 40+ β€” desktop shell with a Node.js main process
  • TypeScript β€” strict mode throughout
  • esbuild β€” fast bundling for both the game and Electron code
  • xterm.js β€” terminal emulator for agent conversations
  • node-pty β€” pseudo-terminal that hosts the Copilot CLI
  • @github/copilot-sdk β€” SDK control plane for the ui-server terminal backend
  • ws β€” WebSocket transport (SDK runtime + Teams real-time receive)

Terminal backends

The terminal server (electron/terminal/server.ts) selects a backend via the COPILOT_TERMINAL_BACKEND environment variable:

  • node-pty (fallback, always available) β€” spawns the real Copilot TUI directly, one PTY per agent
  • ui-server (default) β€” node-pty hosts one copilot --ui-server runtime per office and the Copilot SDK attaches over a local port; automatically falls back to node-pty when the CLI can't host --ui-server
  • sdk (legacy) β€” the SDK spawns its own headless runtime over stdio

Getting Started

Prerequisites

To use the app in full you'll need:

  • Node.js 18+ and npm
  • GitHub Copilot access β€” the agents run the real Copilot CLI, so you must be signed in to a GitHub account with an active Copilot subscription. The CLI runtime ships with the app via the @github/copilot-sdk platform package; on first run, authenticate through the CLI as prompted.
  • (Teams remote agents only) Azure CLI β€” the Teams feature acquires Microsoft Graph and IC3 tokens via az account get-access-token, so you must have the Azure CLI installed and be logged in (az login) with an account that has access to the target Teams channel. This feature is off by default and enabled in Settings.

Install from npm (global command)

npm i -g copilotoffice
copilotoffice

Install from source (development)

git clone https://github.com/dan1510123/CopilotOffice.git
cd CopilotOffice
npm install

# Build and run
npm start

# Development mode (with hot reload)
npm run dev

Controls

Key Action
WASD / Arrow Keys Move around the office
Shift Sprint (2x speed)
E Interact with nearby agent or object
F10 Close terminal
Escape Close terminal or mini-game
Ctrl+Shift+N New terminal session (terminal focused)

Project Structure

CopilotOffice/
β”œβ”€β”€ electron/                    # Electron main process
β”‚   β”œβ”€β”€ main.ts                  # Window, IPC handlers, hot reload
β”‚   β”œβ”€β”€ nonTerminalIpc.ts        # Non-terminal IPC handlers
β”‚   β”œβ”€β”€ officeFileStore.ts       # Office persistence on disk
β”‚   β”œβ”€β”€ cli-bridge.ts            # Legacy placeholder (not used at runtime)
β”‚   β”œβ”€β”€ terminal/                # Terminal server subsystem
β”‚   β”‚   β”œβ”€β”€ server.ts            # PTY/SDK owner (forked child process)
β”‚   β”‚   β”œβ”€β”€ terminal-backend.ts  # Backend selection (node-pty / ui-server / sdk)
β”‚   β”‚   β”œβ”€β”€ pty-registry.ts      # Live PTY/session bookkeeping
β”‚   β”‚   β”œβ”€β”€ agent-viewers.ts     # Active-viewer dual-key invariant helpers
β”‚   β”‚   β”œβ”€β”€ office-foreground.ts # Foreground session selection (ui-server)
β”‚   β”‚   β”œβ”€β”€ session-repair.ts    # Session recovery
β”‚   β”‚   β”œβ”€β”€ ipc-relay.ts         # IPC bridge (renderer ↔ main ↔ server)
β”‚   β”‚   β”œβ”€β”€ preload.ts           # Context bridge (window.copilotBridge)
β”‚   β”‚   β”œβ”€β”€ protocol.ts          # IPC message type definitions
β”‚   β”‚   β”œβ”€β”€ event-source.ts      # Backend-agnostic event source
β”‚   β”‚   └── events-watcher.ts    # Copilot CLI event file parser
β”‚   └── teams/                   # Teams remote agents (main-process service)
β”‚       β”œβ”€β”€ teamsService.ts      # Orchestrator (register/route/reply lifecycle)
β”‚       β”œβ”€β”€ auth.ts              # Graph + IC3 tokens via `az`
β”‚       β”œβ”€β”€ graphClient.ts       # Send channel messages
β”‚       β”œβ”€β”€ trouterClient.ts     # Real-time receive (WebSocket)
β”‚       β”œβ”€β”€ chatsvcClient.ts     # Poll fallback receive
β”‚       β”œβ”€β”€ messageFilter.ts     # Dedup / marker / classify pipeline
β”‚       β”œβ”€β”€ dispatchQueue.ts     # Per-agent FIFO dispatch
β”‚       β”œβ”€β”€ sessionGateway.ts    # Adapter over the terminal server
β”‚       β”œβ”€β”€ onlineAgentsStore.ts # Online-agent persistence + GC
β”‚       └── ...                  # channelLink, marker, chunk, resolvers, IPC
β”œβ”€β”€ src/                         # Renderer process (Phaser + DOM)
β”‚   β”œβ”€β”€ main.ts                  # Entry point β€” DOM layout, Phaser init, IPC wiring
β”‚   β”œβ”€β”€ index.html               # HTML host page
β”‚   β”œβ”€β”€ scenes/                  # Phaser scenes
β”‚   β”‚   β”œβ”€β”€ BootScene.ts         # Procedural sprite generation
β”‚   β”‚   β”œβ”€β”€ OfficeScene.ts       # Main game scene (layout, NPCs, interactions)
β”‚   β”‚   └── MeetingScene.ts      # Meeting room with Arthur for planning
β”‚   β”œβ”€β”€ entities/                # Game entities (Player, NPC)
β”‚   β”œβ”€β”€ sprites/                 # Procedural sprite generation + animation
β”‚   β”œβ”€β”€ ui/                      # DOM overlays
β”‚   β”‚   β”œβ”€β”€ TerminalOverlay.ts   # xterm.js terminal for agent sessions
β”‚   β”‚   β”œβ”€β”€ SeriousTerminalController.ts # Split-pane terminal controller
β”‚   β”‚   β”œβ”€β”€ FleetDashboard.ts    # Fleet execution dashboard
β”‚   β”‚   β”œβ”€β”€ SettingsPanel.ts     # Settings overlay
β”‚   β”‚   β”œβ”€β”€ TeamsSettingsOverlay.ts # Teams feature settings
β”‚   β”‚   β”œβ”€β”€ SpriteCustomizerPanel.ts # Player appearance customization
β”‚   β”‚   β”œβ”€β”€ GalaxianGame.ts      # Galaxian mini-game
β”‚   β”‚   β”œβ”€β”€ PongGame.ts / BasketballGame.ts # Mini-games (feature-flagged)
β”‚   β”‚   β”œβ”€β”€ NotificationService.ts / NotificationSettingsPanel.ts / ToastNotification.ts
β”‚   β”‚   └── CameraDragController.ts / DialogBox.ts
β”‚   β”œβ”€β”€ input/                   # Keyboard focus management (InputManager + listeners)
β”‚   β”œβ”€β”€ office/                  # Multi-office state management (officeManager.ts)
β”‚   β”œβ”€β”€ meeting/                 # Meeting mode & fleet orchestration
β”‚   β”‚   β”œβ”€β”€ types.ts / planParser.ts / planApproval.ts
β”‚   β”‚   └── fleetOrchestrator.ts / fleetTracker.ts / fleetVisualizer.ts
β”‚   β”œβ”€β”€ layouts/                 # Layout system
β”‚   β”‚   β”œβ”€β”€ types.ts / index.ts  # Layout registry + behaviors
β”‚   β”‚   β”œβ”€β”€ default/             # Default office layout
β”‚   β”‚   └── fleet/               # Fleet v-team layout
β”‚   └── config/                  # Static configuration
β”‚       β”œβ”€β”€ agents.ts            # Agent definitions, reserve + fleet config
β”‚       β”œβ”€β”€ depths.ts / zIndex.ts # Phaser depth + DOM z-index constants
β”‚       β”œβ”€β”€ notifications.ts     # Notification event settings
β”‚       β”œβ”€β”€ meetingPrompt.ts     # Meeting coordinator prompt
β”‚       └── playerCustomization.ts # Player color customization
└── dist/                        # Build output

Adding New Agents

Edit src/config/agents.ts to add new NPCs. Six reserve agent slots (Azure, Val, Rex, Doc, Scout, Penny) already have pre-generated sprites β€” activate one by adding its config, or add a brand-new entry to the AGENTS array:

{
  id: 'unique-id',
  name: 'Display Name',
  skill: 'general',
  sprite: 'sprite_key',
  color: 0xff0000,             // Hex color for the procedural sprite
  position: { x: 5, y: 7 },    // Grid position in the office (20Γ—12 tile grid)
  greeting: "Hello message shown when the player approaches",
  description: 'Short description',
  workingDir: 'optional/path', // Optional custom working directory
}

Sprites are auto-generated from the color β€” no image assets needed.

Tip: Don't hardcode agent IDs in scene/layout/dashboard logic. Use the named constants exported from src/config/agents.ts (GENERALIST_AGENT_ID, DEBUGGER_AGENT_ID, ADMIN_AGENT_ID, ARCHITECT_AGENT_ID, DEFAULT_PLAN_AGENT_IDS).

Development

# Watch mode with hot reload
npm run dev

# Build only (no run)
npm run build

# Run without rebuilding
npm run electron

Testing

npm run test          # Vitest unit/integration suite
npm run test:coverage # Vitest with coverage output
npm run test:e2e      # Playwright end-to-end tests (runs a build first)

Release channels

  • Stable: npm i -g copilotoffice (uses the npm latest dist-tag)
  • Beta: npm i -g copilotoffice@beta (uses the npm beta dist-tag)

For maintainers: pushing to GitHub is not enough for npm i -g copilotoffice by name β€” you must publish to npm. Typical flow:

npm run build
npm test
npm version patch
npm publish

# Beta example
npm version prerelease --preid=beta
npm publish --tag beta

License

ISC

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors