(
config: DriverConfig,
cloudAgentSessionId: string,
options: StreamOptions = {}
)
| 428 | { |
| 429 | sourceKiloSessionId: input.sourceKiloSessionId, |
| 430 | sourceCloudAgentSessionId: input.sourceCloudAgentSessionId, |
| 431 | operationKey: input.operationKey ?? randomUUID(), |
| 432 | clientProvenance: 'browser', |
| 433 | ...(config.kilocodeOrganizationId |
| 434 | ? { kilocodeOrganizationId: config.kilocodeOrganizationId } |
| 435 | : {}), |
| 436 | }, |
| 437 | { internalApiSecret: config.internalApiSecret, signal } |
| 438 | ); |
| 439 | // Success only, matching the legacy/unified start pattern. |
| 440 | config.onSessionCreated?.(created.cloudAgentSessionId, created.kiloSessionId); |
| 441 | return created; |
| 442 | } |
| 443 | |
| 444 | /** |
| 445 | * Set or clear the callback target of an existing session through the internal |
| 446 | * `updateSession` endpoint. |
| 447 | * |
| 448 | * The public grouped `start` schema rejects `callbackTarget`, so the new plane's |
| 449 | * callback harness registers the sink after `start` through the same endpoint |
| 450 | * `services/code-review-infra` uses on session continuations. Internal-API |
| 451 | * authenticated. |
| 452 | */ |
| 453 | export async function updateSessionCallbackTarget( |
| 454 | config: DriverConfig, |
| 455 | cloudAgentSessionId: string, |
| 456 | callbackTarget: CallbackTarget | null, |
| 457 | signal?: AbortSignal |
| 458 | ): Promise<{ success: boolean }> { |
| 459 | return trpcCall<{ success: boolean }>( |
| 460 | config, |
| 461 | 'updateSession', |
| 462 | { cloudAgentSessionId, callbackTarget }, |
| 463 | { internalApiSecret: config.internalApiSecret, ...(signal ? { signal } : {}) } |
| 464 | ); |
| 465 | } |
| 466 | |
| 467 | export type SessionSnapshot = { |
| 468 | sessionId: string; |
| 469 | kiloSessionId?: string; |
| 470 | userId: string; |
| 471 | orgId?: string; |
| 472 | sandboxId?: string; |
| 473 | githubRepo?: string; |
| 474 | gitUrl?: string; |
| 475 | platform?: string; |
| 476 | upstreamBranch?: string; |
| 477 | autoCommit?: boolean; |
| 478 | worktreeId?: string | null; |
| 479 | parentSessionId?: string | null; |
| 480 | cloudAgentSessionScopeId?: string | null; |
| 481 | cloudAgentWorktreeId?: string; |
| 482 | initialMessageId?: string; |
| 483 | latestEventId?: number | null; |
| 484 | execution: { id: string; status: string } | null; |
| 485 | }; |
| 486 | |
| 487 | export async function getSessionSnapshot( |
no test coverage detected