import type { GameModelAPI } from '../domains/gameModel.js'; import type { Scalars, SeedPropertyInput } from '../generated/graphql.js'; import type { EngineDetector } from './engine.js'; import { type KitInvokeResult } from './shared.js'; import { type WeatherEvent } from './wire.js'; /** Options for {@link WorldsimKit}. Must match the deployed worldsim blueprint. */ export interface WorldsimKitOptions { /** The `typePrefix` the worldsim blueprint was deployed with. */ typePrefix?: string; /** * The compute module serving `forecast` when the app runs a world engine. * Defaults to `'world-engine'`. */ moduleName?: string; } /** A world engine's forecast (current front + day phase). */ export interface KitForecast { weather: string; /** Day phase in [0, 1) when the engine reports it. */ dayPhase?: number; isNight?: boolean; /** Milliseconds until the current front rolls. */ remainingMs?: number; body: Record; } /** A parsed view of the world clock/weather state. */ export interface KitWorldState { containerId: string; timeOfDay: number; day: number; weather: string; } /** A parsed view of one resource node. */ export interface KitResourceNode { containerId: string; displayName: string; nodeId: string; resourceItemId: string; amount: number; maxAmount: number; regenRate: number; x: number; y: number; z: number; } /** A parsed view of one crop / production job. */ export interface KitCrop { containerId: string; displayName: string; ownerUserId: string | null; stage: number; maxStage: number; outputItemId: string; outputQty: number; ready: boolean; } /** A parsed view of one wave spawner. */ export interface KitWaveSpawner { containerId: string; displayName: string; wave: number; nextWaveSize: number; } /** * Runtime helpers for the {@link worldsimBlueprint} conventions: the world * clock/weather singleton, regenerating resource nodes players gather from, * crops that mature server-side, and wave counters the host reads. The * simulation itself runs in automations — these helpers create/read state * and drive the player-facing functions. * * Obtained via `client.kit(appId).worldsim`. */ export declare class WorldsimKit { private readonly appId; private readonly gameModel; private readonly engines?; private readonly names; private readonly moduleName; constructor(appId: Scalars['BigInt']['input'], gameModel: GameModelAPI, options?: WorldsimKitOptions, engines?: EngineDetector | undefined); /** Is a world compute engine deployed + enabled (cached per session)? */ engineAvailable(): Promise; /** * The world engine's `forecast` invoke: the current weather front plus * day-phase fields. Late joiners call this once, then track transitions * from the type-90 event stream ({@link parseWeather}). */ forecast(): Promise; /** * Parse a server-event payload as a world-engine weather transition * (type 90), or null when it is another event type. Feed it your world * session's server-event stream. */ parseWeather(payload: Uint8Array): WeatherEvent | null; /** * Find-or-create the WorldState singleton (admin). `anchorChunk` is where * the clock's spatial time-changed ping is emitted. */ ensureWorld(options?: { anchorChunk?: { x: number; y: number; z: number; }; displayName?: string; }): Promise<{ __typename?: "GmContainer"; containerId: string; appId: string; sessionId: string | null; typeName: string; displayName: string; description: string | null; ownerUserId: string | null; metadataJson: string; }>; /** Read the world clock/weather state. */ worldState(): Promise; /** Force the weather (app admins only — the policy denies everyone else). */ setWeather(weather: string): Promise>; /** Create a resource node (admin). */ createNode(input: { displayName: string; nodeId: string; resourceItemId: string; amount?: number; maxAmount?: number; regenRate?: number; position?: { x: number; y: number; z: number; }; properties?: SeedPropertyInput[]; }): Promise<{ __typename?: "GmContainer"; containerId: string; appId: string; sessionId: string | null; typeName: string; displayName: string; description: string | null; ownerUserId: string | null; metadataJson: string; }>; /** List resource nodes with parsed state. */ nodes(): Promise; /** * Gather from a node into a caller-owned stack of the node's resource; * the node decrement and the grant commit atomically. Resolves with the * node's remaining amount. */ gather(input: { nodeId: string; amount: number; toStackId: string; }): Promise>; /** Plant a crop / start a production job (member). */ plant(input: { ownerUserId: Scalars['BigInt']['input']; outputItemId: string; outputQty?: number; maxStage?: number; displayName?: string; sessionId?: string; }): Promise<{ __typename?: "GmContainer"; containerId: string; appId: string; sessionId: string | null; typeName: string; displayName: string; description: string | null; ownerUserId: string | null; metadataJson: string; }>; /** List a player's crops (all crops when `ownerUserId` is null). */ crops(ownerUserId: Scalars['BigInt']['input'] | null): Promise; /** * Harvest a grown crop into a caller-owned stack of the output item; * resets the stage for regrowth. Resolves with the yield quantity. */ harvest(cropId: string, toStackId: string): Promise>; /** Create a wave spawner (admin; blueprint deployed with `waves`). */ createSpawner(input: { displayName: string; nextWaveSize?: number; }): Promise<{ __typename?: "GmContainer"; containerId: string; appId: string; sessionId: string | null; typeName: string; displayName: string; description: string | null; ownerUserId: string | null; metadataJson: string; }>; /** List wave spawners (the host reads these to spawn entities). */ spawners(): Promise; /** Run one of the worldsim automations immediately (admin; for testing). */ runNow(automationName: string): Promise<{ __typename?: "GmAutomationRun"; runId: string; appId: string; flowId: string | null; automationId: string | null; automationName: string; triggerSource: string; triggerId: string | null; parentRunId: string | null; cascadeDepth: number; startedAt: string; finishedAt: string | null; durationUs: number; targets: number; invocations: number; mutations: number; fnCalls: number; gasUsed: number; success: boolean; errorMessage: string | null; circuitAction: string | null; computeUnits: number; }>; /** Pause or resume one of the worldsim automations (admin). */ setEnabled(automationName: string, enabled: boolean): Promise<{ __typename?: "GmAutomation"; automationId: string; appId: string; name: string; description: string | null; enabled: boolean; actionKind: string; functionName: string | null; computeModuleName: string | null; computeExport: string | null; targetMode: string; selfContainerId: string | null; targetTypeName: string | null; sessionId: string | null; paramsJson: string; selectorJson: string | null; runAsUserId: string | null; triggerType: string; scheduleKind: string | null; intervalMs: number | null; cronExpr: string | null; maxTargets: number; maxFnDepth: number | null; gasLimit: number | null; runTimeoutMs: number | null; maxRunsPerMinute: number; failureThreshold: number; cooldownMs: number; circuitState: string; consecutiveFailures: number; pausedUntil: string | null; lastError: string | null; lastRunAt: string | null; nextRunAt: string | null; }>; } //# sourceMappingURL=worldsim.d.ts.map