{"_id":"@airtrafficcontrol/tower","name":"@airtrafficcontrol/tower","dist-tags":{"latest":"0.0.1"},"versions":{"0.0.1":{"name":"@airtrafficcontrol/tower","version":"0.0.1","type":"module","main":"./dist/index.js","types":"./dist/index.d.ts","dependencies":{"@airtrafficcontrol/types":"0.0.1","@airtrafficcontrol/errors":"0.0.1","@airtrafficcontrol/core":"0.1.0","@airtrafficcontrol/checklist":"0.0.1"},"scripts":{"build":"tsc --build"},"_id":"@airtrafficcontrol/tower@0.0.1","description":"Merge coordination for the ATC system. The Tower manages landing clearance requests, maintains a first-come-first-served merge queue, and handles emergency declarations. There is exactly one tower per repository.","_integrity":"sha512-Km/hBtkCpesb8Wetbwbta6UAJHq4aMa4ZtBxyBhlnd4yDrIosW/XaYFqP3hOHvwGLzcboaV+lEgWTVh1B3NRIQ==","_resolved":"/private/var/folders/n5/tzqmrds50218kyrpz8166v3w0000gn/T/9302803bc839b85a7d6264c2dd56bca7/airtrafficcontrol-tower-0.0.1.tgz","_from":"file:airtrafficcontrol-tower-0.0.1.tgz","_nodeVersion":"24.11.1","_npmVersion":"11.6.2","dist":{"integrity":"sha512-Km/hBtkCpesb8Wetbwbta6UAJHq4aMa4ZtBxyBhlnd4yDrIosW/XaYFqP3hOHvwGLzcboaV+lEgWTVh1B3NRIQ==","shasum":"3135ec1e463c6aa2dfbd228702b3014f6ff841bf","tarball":"https://registry.npmjs.org/@airtrafficcontrol/tower/-/tower-0.0.1.tgz","fileCount":27,"unpackedSize":68623,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDKZ24Gi6O4HkFE9MMRjXTI266VEUf2kD1a6OOQBKe4aQIhAKBUTZMjQJAw2hpNdioXNNdQh5ObcP8VWU9FwQrcIlmi"}]},"_npmUser":{"name":"mfoulks200","email":"mfoulks1@gmail.com"},"directories":{},"maintainers":[{"name":"mfoulks200","email":"mfoulks1@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/tower_0.0.1_1776908443896_0.6736328851983893"},"_hasShrinkwrap":false}},"time":{"created":"2026-04-23T01:40:43.778Z","0.0.1":"2026-04-23T01:40:44.060Z","modified":"2026-04-23T01:40:44.870Z"},"maintainers":[{"name":"mfoulks200","email":"mfoulks1@gmail.com"}],"description":"Merge coordination for the ATC system. The Tower manages landing clearance requests, maintains a first-come-first-served merge queue, and handles emergency declarations. There is exactly one tower per repository.","readme":"# @airtrafficcontrol/tower\n\nMerge coordination for the ATC system. The Tower manages landing clearance requests, maintains a first-come-first-served merge queue, and handles emergency declarations. There is exactly one tower per repository.\n\n## Installation\n\n```bash\npnpm add @airtrafficcontrol/tower\n```\n\nThis is an internal workspace package (`workspace:*`).\n\n## API Reference\n\n### Types\n\n#### `QueueEntry`\n\nA craft waiting in the merge queue. See `RULE-TMRG-4`.\n\n| Property | Type | Description |\n|---|---|---|\n| `craft` | `Craft` | The craft awaiting merge |\n| `requestedAt` | `Date` | When the craft was added (used for FCFS ordering) |\n\n#### `ClearanceResult`\n\nResult of a landing clearance request. See `RULE-TOWER-2`, `RULE-TMRG-1`.\n\n| Property | Type | Description |\n|---|---|---|\n| `granted` | `boolean` | Whether landing clearance was granted |\n| `reason` | `string?` | If denied, the reason clearance was not granted |\n\n#### `EmergencyReport`\n\nData provided to the origin airport when a craft is returned on emergency. See `RULE-ORIG-2`, `RULE-EMER-4`.\n\n| Property | Type | Description |\n|---|---|---|\n| `callsign` | `string` | The craft's unique identifier |\n| `cargo` | `string` | Description of the change and its scope |\n| `flightPlan` | `FlightPlan` | The ordered sequence of vectors |\n| `blackBox` | `readonly BlackBoxEntry[]` | The complete append-only event log |\n\n### `Tower` Class\n\nThe centralized merge coordination agent. See `RULE-TOWER-1`.\n\n#### `requestClearance(craft: Craft): ClearanceResult`\n\nRequests landing clearance. Verifies all vectors in the flight plan have `Passed` status. If granted, the craft is automatically enqueued for merge.\n\nSee `RULE-TOWER-2`, `RULE-TMRG-1`, `RULE-TMRG-4`.\n\n#### `enqueue(craft: Craft): void`\n\nAdds a craft to the merge queue. Throws `TowerError` if the craft is already queued.\n\nSee `RULE-TMRG-4`.\n\n#### `dequeue(callsign: string): Craft | undefined`\n\nRemoves a craft from the queue by callsign. Returns the removed craft, or `undefined` if not found.\n\n#### `peek(): QueueEntry | undefined`\n\nReturns the next craft in the queue without removing it (FCFS ordering).\n\nSee `RULE-TMRG-4`.\n\n#### `queueSize: number` (getter)\n\nThe number of crafts currently in the merge queue.\n\n#### `declareEmergency(craft: Craft, captainId: string, reason: string): EmergencyReport`\n\nDeclares an emergency for a craft. Only the captain may declare. Appends an `EmergencyDeclaration` entry to the black box, removes the craft from the queue if present, and returns an `EmergencyReport` for the origin airport.\n\nThrows `EmergencyError` if `captainId` does not match the craft's captain.\n\nSee `RULE-EMER-1` through `RULE-EMER-4`, `RULE-ORIG-2`.\n\n### Factory Function\n\n#### `createTower(): Tower`\n\nCreates a new Tower instance with an empty merge queue. See `RULE-TOWER-1`.\n\n### Utility\n\n#### `createEmergencyReport(craft: Craft): EmergencyReport`\n\nExtracts callsign, cargo, flight plan, and black box into an immutable report for the origin airport.\n\nSee `RULE-ORIG-2`, `RULE-EMER-4`, `RULE-BBOX-4`.\n\n## Usage\n\n```typescript\nimport { createTower } from \"@airtrafficcontrol/tower\";\n\nconst tower = createTower();\n\n// Request landing clearance\nconst result = tower.requestClearance(craft);\nif (result.granted) {\n  console.log(`Craft ${craft.callsign} cleared to land (queue position: ${tower.queueSize})`);\n} else {\n  console.log(`Clearance denied: ${result.reason}`);\n}\n\n// Process the merge queue\nconst next = tower.peek();\nif (next) {\n  // Merge the craft's branch, then dequeue\n  tower.dequeue(next.craft.callsign);\n}\n\n// Declare an emergency\nconst report = tower.declareEmergency(craft, \"captain-1\", \"Repeated test failures after 3 go-arounds\");\n```\n\n## Dependencies\n\n| Package | Purpose |\n|---|---|\n| `@airtrafficcontrol/types` | `Craft`, `FlightPlan`, `BlackBoxEntry`, `VectorStatus`, `BlackBoxEntryType` |\n| `@airtrafficcontrol/errors` | `TowerError`, `EmergencyError` |\n| `@airtrafficcontrol/core` | Core runtime functions |\n| `@airtrafficcontrol/checklist` | Checklist types |\n\n## Related Packages\n\n- [`@airtrafficcontrol/core`](../core/) — Craft lifecycle management\n- [`@airtrafficcontrol/errors`](../errors/) — `TowerError` and `EmergencyError`\n- [`@airtrafficcontrol/daemon`](../daemon/) — Hosts the tower as part of the long-running process\n","readmeFilename":"README.md","_rev":"1-3727ed1946c0a43085de9a0660485e87"}