@@ -2,7 +2,7 @@ import { spawn, execSync, spawnSync } from 'child_process'
22import path from 'path'
33import { promises as fs } from 'fs'
44import { logger } from '../utils/logger'
5- import { createGitEnv , createGitIdentityEnv , createGhCliEnv , resolveGitIdentity } from '../utils/git-auth'
5+ import { createGitEnv , createGitIdentityEnv , resolveGitIdentity } from '../utils/git-auth'
66import type { GitCredential } from '@opencode-manager/shared'
77import {
88 buildSSHCommandWithKnownHosts ,
@@ -24,6 +24,8 @@ import { compareVersions } from '../utils/version-utils'
2424import { patchConfigWithRecovery } from './opencode/config-recovery'
2525import type { OpenCodeClient } from './opencode/client'
2626import { writeFileContent } from './file-operations'
27+ import { getOrCreateInternalToken } from './internal-token'
28+ import { installGhEnvPlugin } from './opencode-gh-env-plugin'
2729
2830
2931const MIN_OPENCODE_VERSION = '1.0.137'
@@ -327,6 +329,7 @@ class OpenCodeServerManager {
327329 logger . info ( `OpenCode server GIT_SSH_COMMAND: ${ gitSshCommand } ` )
328330
329331 await this . initializeOpencodeBinDirectory ( )
332+ await installGhEnvPlugin ( path . join ( openCodeServerDirectory , '.config' ) )
330333 const configuredPlugins = await this . getConfiguredPlugins ( openCodeConfigPath )
331334 await this . installConfiguredPlugins ( configuredPlugins )
332335 const configuredPluginCount = configuredPlugins . length
@@ -351,8 +354,13 @@ class OpenCodeServerManager {
351354 ...cleanEnv ,
352355 ...userEnvVars ,
353356 ...gitEnv ,
354- ...createGhCliEnv ( gitCredentials ) ,
355357 ...gitIdentityEnv ,
358+ ...( this . db
359+ ? {
360+ OCM_INTERNAL_API_URL : `http://localhost:${ ENV . SERVER . PORT } /api/internal` ,
361+ OCM_INTERNAL_TOKEN : getOrCreateInternalToken ( this . db ) ,
362+ }
363+ : { } ) ,
356364 GIT_SSH_COMMAND : gitSshCommand ,
357365 XDG_DATA_HOME : path . join ( openCodeServerDirectory , '.opencode/state' ) ,
358366 XDG_STATE_HOME : path . join ( openCodeServerDirectory , '.opencode/state' ) ,
0 commit comments