import type { AgentCommand, AgentServerConfig, AwsCredentials, BrowserCredentials, ChatChunk, CommandResult, DbCredentials, E2eSupportFile, E2eTestStepPayload, EcsAgentRegistration, HeartbeatResponse, PendingAlert, PendingCommand, ProjectConfigResponse, ProjectSharedFileListResponse, ReadSlackThreadResult, ReleaseChannel, ReleaseSelfResult, RegisterRequest, RegisterResponse, RepoCredentials, SendSlackFileResult, SendSlackMessageResult, SelfRestartDeclarationAck, ServerSetupProgressEvent, ServerSetupVariablesResponse, SshCredentials, SshExecCredential, SystemInfo, TriggerAlarmResult, TriggerE2eTestResult, UpdateSystemKnowledgeRequest, UpdateSystemKnowledgeResult, VersionInfo } from './types'; export declare class ApiClient { private readonly client; private readonly retry; private tenantCode; private projectCode; /** This process's replica identity (stable for the process lifetime). */ private readonly instanceId; /** * This process's replica nonce (stable for the process lifetime, distinct * from instanceId — see resolveInstanceNonce). Sent alongside instanceId so * the server can tell apart two processes that report the same instanceId * (e.g. the same StatefulSet Pod name in two different Kubernetes * clusters) and reject the second with `instance_id_conflict` instead of * treating it as a reconnect of the first. */ private readonly instanceNonce; /** Whether this client advertises its replica identity (see constructor). */ private readonly sendsReplicaIdentity; /** * Assignment generation per command (fencing token issued by the server). * * Populated by getCommand and sent back on every later request for that * command, so a replica whose assignment was revoked cannot write results or * fetch credentials with a stale generation. */ private readonly assignmentGenerations; /** * @param options.withoutReplicaIdentity `x-agent-instance-id` ヘッダーと * register/heartbeat ボディの `instanceId` を**送らない**クライアントとして生成する。 * * レプリカ識別子はサーバー側で「AGENT_INSTANCE(稼働枠)を持つ稼働中レプリカ」の * 証として扱われる。register を行わないクライアントがこれを送ると、 * - コマンド取得はクレーム機構の要求元検証で必ず落ちて 409(ECS oneshot) * - ハートビートは `evicted` 扱いで AGENT_STATUS が一切更新されない * (ホスト側の自動更新エラー通知が消える) * という形でサイレントに壊れる。register を経由しない用途では必ず true にすること。 */ constructor(apiUrl: string, token: string, options?: { withoutReplicaIdentity?: boolean; instanceId?: string; }); setTenantCode(code: string): void; /** * Read-only accessor for the tenant code derived from the current token * (or overridden via `setTenantCode`). Used by `server-setup-runner.ts` to * namespace the persistent per-host known_hosts file so distinct tenants * never share (or overwrite) each other's recorded SSH host keys. */ getTenantCode(): string; setProjectCode(code: string): void; updateToken(newToken: string): void; private get; private post; private postVoid; private putVoid; /** * Read-only accessor for this process's replica identity. Callers use it to * label log lines and to correlate an eviction notice with the local process. */ getInstanceId(): string; /** * Register this agent. * * `instanceId` is always sent so the server can apply the plan's replica * limit. `admissionMode` defaults to `initial`; the standby loop passes * `standby` so the server admits it only into a free slot. */ register(request: RegisterRequest): Promise; heartbeat(agentId: string, systemInfo: SystemInfo, updateError?: string, availableChatModes?: string[], activeChatMode?: string, ipAddress?: string, configHash?: string, dockerBuildError?: string, authRejectedTransports?: string[], /** * 追加の報告項目。 * * 位置引数が既に多く、これ以上増やすと呼び出し側の可読性が落ちるため、 * 新規項目はこのオブジェクトへまとめる(既存の位置引数は互換のため残す)。 */ extras?: { /** 共有ファイルの配置に失敗したもの(画面に警告として出す) */ sharedFileMountErrors?: { destPath: string; error: string; }[]; }): Promise; /** * Fetch the tenant's concurrent replica limit (`null` = unlimited). * * Used by `manifest` to refuse generating a Deployment that exceeds the * plan before anything is written. */ getReplicaLimit(): Promise<{ maxReplicas: number | null; }>; /** * Release this replica's slot as the last step of a graceful shutdown drain * (see `ProjectAgent.shutdown`). Called only after all in-flight commands * have finished, so the server can hand the slot to a standby replica * immediately instead of waiting for the heartbeat-timeout reclaim. * * Deliberately bypasses `this.retry` (RetryStrategy retries 3x with backoff — * worst case ~33s — which would blow the shutdown time budget) and never * throws: any failure (network, timeout, non-2xx, malformed response) is * reported as `{ released: false, reason: 'request_failed' }` so the caller * can log it and move on to exiting the process regardless. */ releaseSelf(): Promise; getVersionInfo(channel?: ReleaseChannel): Promise; getPendingCommands(agentId: string): Promise; private validateCommandId; getCommand(commandId: string, agentId: string): Promise; /** Forget a command's assignment generation (call when execution ends). */ clearAssignment(commandId: string): void; /** The assignment generation currently held for a command, if any. */ getAssignmentGeneration(commandId: string): number | undefined; /** * Restore an assignment generation obtained by an earlier process. * * Used when re-submitting a result saved before a restart: the fencing token * belongs to the execution that produced the result, not to this process. * Without it the request carries no generation, the server treats it as * "not claiming an assignment", and the write is refused for an assigned * command — silently discarding a result that was computed correctly. */ restoreAssignment(commandId: string, generation: number): void; /** * Headers carrying the assignment for a command, when we hold one. * * Omitted for clients that do not send a replica identity (oneshot, the * host auto-updater) and for commands fetched before the server started * assigning — those keep the pre-assignment behaviour. */ private assignmentHeaders; /** * Report mid-run server-setup progress for a `server_setup_exec` command. * * Best-effort by contract: the authoritative per-task results still arrive * through {@link submitResult}, so callers treat a rejection here as a * skipped update rather than a failed run. The assignment headers are sent * for the same reason as on {@link submitResult} — a replica that lost the * assignment must not keep writing progress for a command it no longer owns. */ submitServerSetupProgress(commandId: string, events: ServerSetupProgressEvent[], agentId: string): Promise; /** * Report that this run is about to restart the agent executing it. * * Rides {@link submitServerSetupProgress}'s endpoint — there is no separate * one — with the `awaitingSelfRestart` latch instead of events. The execution * is derived server-side from the command's payload, so no executionId / * projectCode is sent from here (a client-chosen one would let a command * flag someone else's execution). * * Idempotent server-side and one-way: only `true` carries meaning. Rejections * are the caller's to absorb — see self-restart-declaration.ts, which reports * the failure and lets the deployment proceed. * * **A 200 is not proof the declaration landed.** The api applies the flag on * a best-effort path (its own exceptions are logged, not raised) and answers * 200 either way, so the outcome is carried in the response body instead. * This is the last answer this process will ever read — it restarts itself * immediately afterwards — which is why the caller must look at it. * * A body-less 200 means an api that predates that field; it is read as * acknowledged. Reading it as a failure would turn every run against a * not-yet-deployed api into a false alarm and bury the real ones. */ declareServerSetupAwaitingSelfRestart(commandId: string, agentId: string): Promise; submitResult(commandId: string, result: CommandResult, agentId: string): Promise; reportConnectionStatus(agentId: string, status: 'connected' | 'disconnected'): Promise; getConfig(): Promise; getProjectConfig(): Promise; getAwsCredentials(awsAccountId: string): Promise; getDbCredentials(name: string): Promise; getSshCredentials(hostId: string): Promise; /** * Shared implementation for the commandId-scoped JIT lookups below * (`getServerSetupSshCredential` / `getServerSetupVariables` / * `getSshExecCredential`): validate the commandId, log at debug level, and * GET the given endpoint with `agentId` as a query param. Extracted because * all three otherwise repeated this exact sequence verbatim. */ private getCommandScopedResource; /** * JIT SSH credential lookup for a `server_setup_exec` command. The target * host is resolved server-side from the command's payload (never from a * client-supplied hostId), so this can safely be called with either an * ECS oneshot token or a resident agent's normal token. The response may * carry Tailscale SOCKS5 fields (connectionType / tailnetHostname / * socksPort / tailscaleAuthKey) the same way `getSshExecCredential`'s does * — see `SshExecCredential` and `server-setup-runner.ts`'s * `buildInventory`. Never log the returned credential; only log the * commandId. */ getServerSetupSshCredential(commandId: string, agentId: string): Promise; /** * JIT lookup of project (`ANSIBLE#`-prefixed `ConfigSetting`) variables for * a `server_setup_exec` command's custom Ansible tasks. Mirrors * `getServerSetupSshCredential`'s IDOR-prevention design: `projectCode` is * resolved server-side from the command's `requestContext`, never passed * by the caller. `secretNames` in the response drives `no_log: true` * annotation (`ansible-task-guard.ts`) and post-execution redaction * (`server-setup-runner.ts`) — never log the returned `variables` values. */ getServerSetupVariables(commandId: string, agentId: string): Promise; /** * JIT SSH credential lookup for an `ssh_exec` command. Mirrors * `getServerSetupSshCredential`'s commandId-scoped design: the target host * is resolved server-side from the command's payload, so this can safely * be called with either an ECS oneshot token or a resident agent's normal * token. The response may carry Tailscale SOCKS5 fields (connectionType / * tailnetHostname / socksPort / tailscaleAuthKey) — see `SshExecCredential`. * Never log the returned credential; only log the commandId. */ getSshExecCredential(commandId: string, agentId: string): Promise; getBrowserCredentials(name: string): Promise; getE2eEnvironmentVariables(environmentId: string): Promise>; /** * プロジェクト共有の E2E サポートファイル(Playwright spec から相対 import * されるヘルパー群、例: `lib/login.page.ts`)を取得する。 */ getE2eSupportFiles(tenantCode: string, projectCode: string): Promise; getRepoCredentials(repositoryId: string): Promise; submitChatChunk(commandId: string, chunk: ChatChunk, agentId: string): Promise; submitLogChunk(params: { agentId: string; projectCode: string; logType: 'docker-build' | 'container'; sessionId: string; seq: number; text: string; }): Promise; saveSessionLog(params: { agentId: string; projectCode: string; logType: 'docker-build' | 'container'; sessionId: string; content: string; }): Promise; getUploadUrl(data: { conversationId: string; messageId: string; filename: string; contentType: string; fileSize: number; projectCode: string; }): Promise<{ uploadUrl: string; fileId: string; s3Key: string; }>; getDownloadUrl(data: { fileId: string; s3Key: string; }): Promise<{ downloadUrl: string; }>; /** * プロジェクト共有フォルダのエントリ一覧を取得する。 * * `path` 省略時はルート直下。エージェントトークンで認証し、テナント/プロジェクトは * サーバー側がトークンから解決するため、他プロジェクトのファイルは構造上参照できない。 */ listProjectFiles(path?: string): Promise; /** * プロジェクト共有ファイルの署名付きダウンロードURLを取得する。 * * ファイルIDではなくパスで指定する(LLM が一覧の path をそのまま使えるようにするため)。 */ getProjectFileDownloadUrl(path: string): Promise<{ downloadUrl: string; filename: string; contentType: string; }>; updateE2eExecutionStatus>(tenantCode: string, projectCode: string, executionId: string, body: B): Promise; reportE2eTestStep(tenantCode: string, projectCode: string, executionId: string, body: B): Promise; updateE2eTestScript>(tenantCode: string, projectCode: string, executionId: string, body: B): Promise; /** * pending のアラートのみを取得する(通常の高頻度ポーリング用)。 * processing のアラートは含めない。これにより、処理が完了しない(processing で * 止まった)アラートを毎回拾って再処理する無限ループを防ぐ。 */ getPendingAlerts(tenantCode: string, projectCode: string): Promise<{ items: PendingAlert[]; total: number; }>; /** * 指定分数以上 processing のままスタックしたアラートを取得する * (低頻度のスタック救済フロー専用)。 * 通常ポーリング(getPendingAlerts)とは分離し、再処理の頻度を抑える。 */ getStaleProcessingAlerts(tenantCode: string, projectCode: string, staleProcessingMinutes: number): Promise<{ items: PendingAlert[]; total: number; }>; getAlert(tenantCode: string, projectCode: string, alertNumber: string): Promise; updateAlertStatus(tenantCode: string, projectCode: string, alertNumber: string, body: { status: string; issueId?: string; failureReason?: string; }): Promise; /** 同じ alarmName の未解決 Issue(open/received/in_progress)を検索する */ findActiveIssueByAlarmName(tenantCode: string, projectCode: string, alarmName: string): Promise<{ id: string; } | null>; /** OK 通知(アラーム解除)時に既存 Issue を resolved に更新する */ resolveIssueFromAlert(tenantCode: string, projectCode: string, alertNumber: string, issueId: string): Promise; /** * Register (or overwrite on re-publish) an ECS execution agent. * The API only validates and persists the AGENT record; it never calls AWS. */ registerEcsAgent(registration: EcsAgentRegistration): Promise; sendSlackMessage(channel: string, message: string, threadTs?: string, callId?: string): Promise; sendSlackFile(channel: string, fileName: string, content: string, threadTs?: string, callId?: string): Promise; /** * 現在処理中のSlackスレッドの全文を読み取る(自ボットの過去投稿を含む)。 * * `chatConversationId` は `send_slack_message`/`trigger_alarm` の `callId` * (呼び出し単位の冪等キー)とは別物で、実際のSlackチャット会話ID * (`SlackThreadMapping.conversationId`)そのものを渡す。 */ readSlackThread(chatConversationId: string): Promise; triggerAlarm(title: string, reason: string, priority?: 'urgent' | 'high' | 'medium' | 'low', callId?: string): Promise; /** * タスク実行中の CLI エージェントが E2E テストを起動する。 * * `taskId` を渡すことで、起動した E2E 実行がそのタスクに紐付き、 * タスク詳細画面の E2E テストタブから逆引きできるようになる。 */ triggerE2eTest(testCaseId: string, taskId: string, executionMethod?: 'ai' | 'script' | 'hybrid' | 'playwright', environmentId?: string, callId?: string): Promise; /** * システムのナレッジベースへ登録・改訂する(`update_system_knowledge` MCPツール専用)。 * * `id` を指定すると改訂、未指定なら新規作成として扱われる。他の `agent/tools/*` * エンドポイントと異なり `{success, data, error}` ではなく、成功時(201)はナレッジ詳細 * オブジェクトを直接返す。失敗時(4xx/5xx・ネットワークエラー)は例外を投げる * (呼び出し元は `withMcpErrorHandling` でエラーレスポンスに変換し、ローカルファイルへの * フォールバックは行わない)。 */ updateSystemKnowledge(request: UpdateSystemKnowledgeRequest): Promise; } //# sourceMappingURL=api-client.d.ts.map