GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — headlesscode/src/rsi/roles.ts at master · Capsize-Games/headlesscode

Expand file tree

/

roles.ts

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
59 lines (55 loc) · 2.68 KB
/

roles.ts

Copy path

File metadata and controls

59 lines (55 loc) · 2.68 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import { DEFAULT_RSI_MODEL } from "./config.js"
import { openRouterProfileForModel, RSI_DEFAULT_OPENROUTER_PROFILE_ID } from "./inference-broker.js"
import type { ModelRole, RsiRoleConfig, RoleModelConfig } from "./types.js"
const ROLE_ENV_NAMES: ModelRole[] = [
"worker",
"mutation-architect",
"failure-analyst",
"critic",
"adversary",
"reviewer",
"curriculum-designer",
"training-data-curator",
]
function envKey(role: ModelRole): string {
return `HEADLESSCODE_RSI_ROLE_${role.toUpperCase().replace(/-/g, "_")}_MODEL`
}
export function defaultRoles(workerModel = DEFAULT_RSI_MODEL): RsiRoleConfig {
return { worker: { provider: "ollama", model: workerModel } }
}
export function resolveRoles(
configured: RsiRoleConfig | undefined,
env: NodeJS.ProcessEnv = process.env,
workerModel = DEFAULT_RSI_MODEL,
): RsiRoleConfig {
const roles: RsiRoleConfig = { ...defaultRoles(workerModel), ...configured }
for (const role of ROLE_ENV_NAMES) {
const model = env[envKey(role)]
const prefix = `HEADLESSCODE_RSI_ROLE_${role.toUpperCase().replace(/-/g, "_")}_`
const provider = env[`${prefix}PROVIDER`]?.trim()
const baseUrl = env[`${prefix}BASE_URL`]?.trim()
const command = env[`${prefix}COMMAND`]?.trim()
const openRouterProfile = env[`${prefix}OPENROUTER_PROFILE`]?.trim()
if (provider && !["ollama", "openrouter", "command"].includes(provider)) throw new Error(`${prefix}PROVIDER must be ollama, openrouter, or command`)
if (openRouterProfile && role !== "worker") throw new Error(`${prefix}OPENROUTER_PROFILE is supported only for worker jobs`)
if (openRouterProfile && !(openRouterProfile === "deepseek-deepinfra-fp8" || openRouterProfile === "muse-spark-contributor")) throw new Error(`${prefix}OPENROUTER_PROFILE is not an admitted RSI profile`)
if (model || provider || baseUrl || command || openRouterProfile) {
roles[role] = {
...(roles[role] ?? { provider: "ollama" as const, model: workerModel }),
...(model ? { model } : {}),
...(provider ? { provider: provider as RoleModelConfig["provider"] } : {}),
...(baseUrl ? { baseUrl } : {}),
...(command ? { command } : {}),
...(openRouterProfile ? { openRouterProfile: openRouterProfile as NonNullable<RoleModelConfig["openRouterProfile"]> } : {}),
}
}
}
const worker = roles.worker
if (worker?.provider === "openrouter") {
const profile = openRouterProfileForModel(worker.model, worker.openRouterProfile)
if (profile.id !== RSI_DEFAULT_OPENROUTER_PROFILE_ID || worker.openRouterProfile) roles.worker = { ...worker, openRouterProfile: profile.id }
} else if (worker?.openRouterProfile) {
throw new Error("HEADLESSCODE_RSI_ROLE_WORKER_OPENROUTER_PROFILE requires the OpenRouter worker provider")
}
return roles
}
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.