@kmmao/happy-wire 0.11.12 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1186,6 +1186,68 @@ const AgentMessageSummarySchema = z__namespace.object({
1186
1186
  updatedAt: z__namespace.number()
1187
1187
  });
1188
1188
 
1189
+ const CODEX_APP_SERVER_BACKEND = "codex-app-server";
1190
+ const CODEX_MCP_LEGACY_BACKEND = "codex-mcp-legacy";
1191
+ const CodexBackendModeSchema = z__namespace.enum([
1192
+ "auto",
1193
+ CODEX_APP_SERVER_BACKEND,
1194
+ CODEX_MCP_LEGACY_BACKEND
1195
+ ]);
1196
+ const CodexRequestedBackendSchema = CodexBackendModeSchema;
1197
+ const CodexResolvedBackendSchema = z__namespace.enum([
1198
+ CODEX_APP_SERVER_BACKEND,
1199
+ CODEX_MCP_LEGACY_BACKEND
1200
+ ]);
1201
+ const CodexConfigModeSchema = z__namespace.enum([
1202
+ "inherit",
1203
+ "managed-profile",
1204
+ "managed-overrides"
1205
+ ]);
1206
+ const CODEX_REQUESTED_BACKEND_ALIASES = {
1207
+ auto: ["", "auto"],
1208
+ [CODEX_APP_SERVER_BACKEND]: ["app-server", "appserver", CODEX_APP_SERVER_BACKEND],
1209
+ [CODEX_MCP_LEGACY_BACKEND]: [
1210
+ "legacy",
1211
+ "mcp",
1212
+ "mcp-legacy",
1213
+ CODEX_MCP_LEGACY_BACKEND
1214
+ ]
1215
+ };
1216
+ const CODEX_REQUESTED_BACKEND_ALIAS_TO_VALUE = new Map(
1217
+ Object.entries(CODEX_REQUESTED_BACKEND_ALIASES).flatMap(
1218
+ ([backend, aliases]) => aliases.map((alias) => [alias, backend])
1219
+ )
1220
+ );
1221
+ function resolveRequestedCodexBackend(rawValue) {
1222
+ const normalizedAlias = (rawValue || "").trim().toLowerCase();
1223
+ return CODEX_REQUESTED_BACKEND_ALIAS_TO_VALUE.get(normalizedAlias) ?? "auto";
1224
+ }
1225
+ function isCodexAppServerBackend(value) {
1226
+ return value === CODEX_APP_SERVER_BACKEND;
1227
+ }
1228
+ function isCodexLegacyBackend(value) {
1229
+ return value === CODEX_MCP_LEGACY_BACKEND;
1230
+ }
1231
+ function resolveCodexResolvedBackend(requestedBackend, appServerSupported) {
1232
+ if (isCodexLegacyBackend(requestedBackend)) {
1233
+ return CODEX_MCP_LEGACY_BACKEND;
1234
+ }
1235
+ if (isCodexAppServerBackend(requestedBackend)) {
1236
+ return CODEX_APP_SERVER_BACKEND;
1237
+ }
1238
+ return appServerSupported ? CODEX_APP_SERVER_BACKEND : CODEX_MCP_LEGACY_BACKEND;
1239
+ }
1240
+ function resolveCodexResumableThreadId(value) {
1241
+ const threadId = value?.threadId;
1242
+ if (!threadId) {
1243
+ return null;
1244
+ }
1245
+ if (isCodexLegacyBackend(value?.resolvedBackend)) {
1246
+ return null;
1247
+ }
1248
+ return threadId;
1249
+ }
1250
+
1189
1251
  function isTemplateAwareUrl(value) {
1190
1252
  if (!value) return true;
1191
1253
  if (/^\$\{[A-Z_][A-Z0-9_]*(:-[^}]*)?\}$/.test(value)) return true;
@@ -1244,8 +1306,8 @@ const TogetherAIConfigSchema = z.z.object({
1244
1306
  model: z.z.string().optional()
1245
1307
  });
1246
1308
  const CodexConfigSchema = z.z.object({
1247
- backendMode: z.z.enum(["auto", "codex-app-server", "codex-mcp-legacy"]).optional(),
1248
- configMode: z.z.enum(["inherit", "managed-profile", "managed-overrides"]).optional(),
1309
+ backendMode: CodexBackendModeSchema.optional(),
1310
+ configMode: CodexConfigModeSchema.optional(),
1249
1311
  codexProfileName: z.z.string().optional(),
1250
1312
  model: z.z.string().optional(),
1251
1313
  reasoningEffort: z.z.string().optional(),
@@ -1328,6 +1390,229 @@ const ResolvedRuntimeProfileSchema = z.z.object({
1328
1390
  defaultPermissionMode: DefaultPermissionModeSchema.optional(),
1329
1391
  defaultModelMode: z.z.string().optional()
1330
1392
  });
1393
+ function getBuiltInAIBackendProfile(id) {
1394
+ switch (id) {
1395
+ case "anthropic":
1396
+ return {
1397
+ id: "anthropic",
1398
+ name: "Anthropic (Default)",
1399
+ anthropicConfig: {},
1400
+ environmentVariables: [],
1401
+ defaultPermissionMode: "default",
1402
+ compatibility: { claude: true, codex: false, gemini: false },
1403
+ isBuiltIn: true,
1404
+ createdAt: Date.now(),
1405
+ updatedAt: Date.now(),
1406
+ version: "1.0.0"
1407
+ };
1408
+ case "deepseek":
1409
+ return {
1410
+ id: "deepseek",
1411
+ name: "DeepSeek (Reasoner)",
1412
+ anthropicConfig: {},
1413
+ environmentVariables: [
1414
+ {
1415
+ name: "ANTHROPIC_BASE_URL",
1416
+ value: "${DEEPSEEK_BASE_URL:-https://api.deepseek.com/anthropic}"
1417
+ },
1418
+ { name: "ANTHROPIC_AUTH_TOKEN", value: "${DEEPSEEK_AUTH_TOKEN}" },
1419
+ {
1420
+ name: "API_TIMEOUT_MS",
1421
+ value: "${DEEPSEEK_API_TIMEOUT_MS:-600000}"
1422
+ },
1423
+ {
1424
+ name: "ANTHROPIC_MODEL",
1425
+ value: "${DEEPSEEK_MODEL:-deepseek-reasoner}"
1426
+ },
1427
+ {
1428
+ name: "ANTHROPIC_SMALL_FAST_MODEL",
1429
+ value: "${DEEPSEEK_SMALL_FAST_MODEL:-deepseek-chat}"
1430
+ },
1431
+ {
1432
+ name: "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC",
1433
+ value: "${DEEPSEEK_CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC:-1}"
1434
+ }
1435
+ ],
1436
+ defaultPermissionMode: "default",
1437
+ compatibility: { claude: true, codex: false, gemini: false },
1438
+ isBuiltIn: true,
1439
+ createdAt: Date.now(),
1440
+ updatedAt: Date.now(),
1441
+ version: "1.0.0"
1442
+ };
1443
+ case "zai":
1444
+ return {
1445
+ id: "zai",
1446
+ name: "Z.AI (GLM-4.6)",
1447
+ anthropicConfig: {},
1448
+ environmentVariables: [
1449
+ {
1450
+ name: "ANTHROPIC_BASE_URL",
1451
+ value: "${Z_AI_BASE_URL:-https://api.z.ai/api/anthropic}"
1452
+ },
1453
+ { name: "ANTHROPIC_AUTH_TOKEN", value: "${Z_AI_AUTH_TOKEN}" },
1454
+ { name: "API_TIMEOUT_MS", value: "${Z_AI_API_TIMEOUT_MS:-3000000}" },
1455
+ { name: "ANTHROPIC_MODEL", value: "${Z_AI_MODEL:-GLM-4.6}" },
1456
+ {
1457
+ name: "ANTHROPIC_DEFAULT_OPUS_MODEL",
1458
+ value: "${Z_AI_OPUS_MODEL:-GLM-4.6}"
1459
+ },
1460
+ {
1461
+ name: "ANTHROPIC_DEFAULT_SONNET_MODEL",
1462
+ value: "${Z_AI_SONNET_MODEL:-GLM-4.6}"
1463
+ },
1464
+ {
1465
+ name: "ANTHROPIC_DEFAULT_HAIKU_MODEL",
1466
+ value: "${Z_AI_HAIKU_MODEL:-GLM-4.5-Air}"
1467
+ }
1468
+ ],
1469
+ defaultPermissionMode: "default",
1470
+ compatibility: { claude: true, codex: false, gemini: false },
1471
+ isBuiltIn: true,
1472
+ createdAt: Date.now(),
1473
+ updatedAt: Date.now(),
1474
+ version: "1.0.0"
1475
+ };
1476
+ case "openai":
1477
+ return {
1478
+ id: "openai",
1479
+ name: "OpenAI (GPT-5.4)",
1480
+ openaiConfig: {},
1481
+ environmentVariables: [
1482
+ { name: "OPENAI_BASE_URL", value: "https://api.openai.com/v1" },
1483
+ { name: "OPENAI_MODEL", value: "gpt-5.4" },
1484
+ { name: "OPENAI_API_TIMEOUT_MS", value: "600000" },
1485
+ { name: "OPENAI_SMALL_FAST_MODEL", value: "gpt-5.4" },
1486
+ { name: "API_TIMEOUT_MS", value: "600000" },
1487
+ { name: "CODEX_SMALL_FAST_MODEL", value: "gpt-5.4" }
1488
+ ],
1489
+ compatibility: { claude: false, codex: true, gemini: false },
1490
+ isBuiltIn: true,
1491
+ createdAt: Date.now(),
1492
+ updatedAt: Date.now(),
1493
+ version: "1.0.0"
1494
+ };
1495
+ case "azure-openai":
1496
+ return {
1497
+ id: "azure-openai",
1498
+ name: "Azure OpenAI",
1499
+ azureOpenAIConfig: {},
1500
+ environmentVariables: [
1501
+ { name: "AZURE_OPENAI_API_VERSION", value: "2024-02-15-preview" },
1502
+ { name: "AZURE_OPENAI_DEPLOYMENT_NAME", value: "gpt-5.4" },
1503
+ { name: "OPENAI_API_TIMEOUT_MS", value: "600000" },
1504
+ { name: "API_TIMEOUT_MS", value: "600000" }
1505
+ ],
1506
+ compatibility: { claude: false, codex: true, gemini: false },
1507
+ isBuiltIn: true,
1508
+ createdAt: Date.now(),
1509
+ updatedAt: Date.now(),
1510
+ version: "1.0.0"
1511
+ };
1512
+ case "minimax":
1513
+ return {
1514
+ id: "minimax",
1515
+ name: "MiniMax (M2.7)",
1516
+ anthropicConfig: {},
1517
+ environmentVariables: [
1518
+ {
1519
+ name: "ANTHROPIC_BASE_URL",
1520
+ value: "${MINIMAX_BASE_URL:-https://api.minimaxi.com/anthropic}"
1521
+ },
1522
+ {
1523
+ name: "ANTHROPIC_AUTH_TOKEN",
1524
+ value: "${MINIMAX_AUTH_TOKEN}"
1525
+ },
1526
+ {
1527
+ name: "API_TIMEOUT_MS",
1528
+ value: "${MINIMAX_API_TIMEOUT_MS:-3000000}"
1529
+ },
1530
+ {
1531
+ name: "ANTHROPIC_MODEL",
1532
+ value: "${MINIMAX_MODEL:-MiniMax-M2.7}"
1533
+ },
1534
+ {
1535
+ name: "ANTHROPIC_SMALL_FAST_MODEL",
1536
+ value: "${MINIMAX_SMALL_FAST_MODEL:-MiniMax-M2.7-highspeed}"
1537
+ },
1538
+ {
1539
+ name: "ANTHROPIC_DEFAULT_OPUS_MODEL",
1540
+ value: "${MINIMAX_OPUS_MODEL:-MiniMax-M2.7}"
1541
+ },
1542
+ {
1543
+ name: "ANTHROPIC_DEFAULT_SONNET_MODEL",
1544
+ value: "${MINIMAX_SONNET_MODEL:-MiniMax-M2.7}"
1545
+ },
1546
+ {
1547
+ name: "ANTHROPIC_DEFAULT_HAIKU_MODEL",
1548
+ value: "${MINIMAX_HAIKU_MODEL:-MiniMax-M2.7-highspeed}"
1549
+ },
1550
+ {
1551
+ name: "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC",
1552
+ value: "1"
1553
+ }
1554
+ ],
1555
+ defaultPermissionMode: "default",
1556
+ compatibility: { claude: true, codex: false, gemini: false },
1557
+ isBuiltIn: true,
1558
+ createdAt: Date.now(),
1559
+ updatedAt: Date.now(),
1560
+ version: "1.0.0"
1561
+ };
1562
+ case "kimi":
1563
+ return {
1564
+ id: "kimi",
1565
+ name: "Kimi (K2.5)",
1566
+ anthropicConfig: {},
1567
+ environmentVariables: [
1568
+ {
1569
+ name: "ANTHROPIC_BASE_URL",
1570
+ value: "${KIMI_BASE_URL:-https://api.moonshot.ai/anthropic}"
1571
+ },
1572
+ {
1573
+ name: "ANTHROPIC_AUTH_TOKEN",
1574
+ value: "${KIMI_AUTH_TOKEN}"
1575
+ },
1576
+ {
1577
+ name: "API_TIMEOUT_MS",
1578
+ value: "${KIMI_API_TIMEOUT_MS:-3000000}"
1579
+ },
1580
+ {
1581
+ name: "ANTHROPIC_MODEL",
1582
+ value: "${KIMI_MODEL:-kimi-k2.5}"
1583
+ },
1584
+ {
1585
+ name: "ANTHROPIC_SMALL_FAST_MODEL",
1586
+ value: "${KIMI_SMALL_FAST_MODEL:-kimi-k2.5}"
1587
+ },
1588
+ {
1589
+ name: "ANTHROPIC_DEFAULT_OPUS_MODEL",
1590
+ value: "${KIMI_OPUS_MODEL:-kimi-k2.5}"
1591
+ },
1592
+ {
1593
+ name: "ANTHROPIC_DEFAULT_SONNET_MODEL",
1594
+ value: "${KIMI_SONNET_MODEL:-kimi-k2.5}"
1595
+ },
1596
+ {
1597
+ name: "ANTHROPIC_DEFAULT_HAIKU_MODEL",
1598
+ value: "${KIMI_HAIKU_MODEL:-kimi-k2.5}"
1599
+ },
1600
+ {
1601
+ name: "ENABLE_TOOL_SEARCH",
1602
+ value: "${KIMI_ENABLE_TOOL_SEARCH:-false}"
1603
+ }
1604
+ ],
1605
+ defaultPermissionMode: "default",
1606
+ compatibility: { claude: true, codex: false, gemini: false },
1607
+ isBuiltIn: true,
1608
+ createdAt: Date.now(),
1609
+ updatedAt: Date.now(),
1610
+ version: "1.0.0"
1611
+ };
1612
+ default:
1613
+ return null;
1614
+ }
1615
+ }
1331
1616
  function validateProfileForAgent(profile, agent) {
1332
1617
  return profile.compatibility[agent];
1333
1618
  }
@@ -1728,6 +2013,72 @@ function shouldAutoApproveHappyMcpReason(reason) {
1728
2013
  );
1729
2014
  }
1730
2015
 
2016
+ const CodexRuntimeConfigSchema = z__namespace.object({
2017
+ model: z__namespace.string().nullish(),
2018
+ profile: z__namespace.string().nullish(),
2019
+ approvalPolicy: z__namespace.string().nullish(),
2020
+ sandboxMode: z__namespace.string().nullish(),
2021
+ serviceTier: z__namespace.string().nullish(),
2022
+ reasoningEffort: z__namespace.string().nullish(),
2023
+ reasoningSummary: z__namespace.string().nullish(),
2024
+ verbosity: z__namespace.string().nullish(),
2025
+ webSearch: z__namespace.string().nullish()
2026
+ });
2027
+ const CodexAccountSchema = z__namespace.object({
2028
+ type: z__namespace.enum(["apiKey", "chatgpt"]).nullable().optional(),
2029
+ email: z__namespace.string().nullish(),
2030
+ planType: z__namespace.string().nullish(),
2031
+ requiresOpenaiAuth: z__namespace.boolean().optional()
2032
+ });
2033
+ const CodexRateLimitsSchema = z__namespace.object({
2034
+ limitId: z__namespace.string().nullish(),
2035
+ limitName: z__namespace.string().nullish(),
2036
+ planType: z__namespace.string().nullish(),
2037
+ hasCredits: z__namespace.boolean().optional()
2038
+ });
2039
+ const CodexExperimentalFeatureSchema = z__namespace.object({
2040
+ name: z__namespace.string(),
2041
+ stage: z__namespace.string(),
2042
+ enabled: z__namespace.boolean(),
2043
+ defaultEnabled: z__namespace.boolean()
2044
+ });
2045
+ const CodexSkillSummarySchema = z__namespace.object({
2046
+ name: z__namespace.string(),
2047
+ description: z__namespace.string(),
2048
+ path: z__namespace.string(),
2049
+ enabled: z__namespace.boolean()
2050
+ });
2051
+ const CodexPromptSummarySchema = z__namespace.object({
2052
+ name: z__namespace.string(),
2053
+ path: z__namespace.string(),
2054
+ description: z__namespace.string().nullish()
2055
+ });
2056
+ const CodexAgentSummarySchema = z__namespace.object({
2057
+ name: z__namespace.string(),
2058
+ path: z__namespace.string()
2059
+ });
2060
+ const CodexMcpServerSummarySchema = z__namespace.object({
2061
+ name: z__namespace.string(),
2062
+ authStatus: z__namespace.string(),
2063
+ toolCount: z__namespace.number()
2064
+ });
2065
+ const CodexMetadataSchema = z__namespace.object({
2066
+ requestedBackend: CodexRequestedBackendSchema.optional(),
2067
+ resolvedBackend: CodexResolvedBackendSchema.optional(),
2068
+ configMode: CodexConfigModeSchema.optional(),
2069
+ fallbackReason: z__namespace.string().optional(),
2070
+ backendVersion: z__namespace.string().optional(),
2071
+ threadId: z__namespace.string().optional(),
2072
+ config: CodexRuntimeConfigSchema.optional(),
2073
+ account: CodexAccountSchema.optional(),
2074
+ rateLimits: CodexRateLimitsSchema.optional(),
2075
+ experimentalFeatures: z__namespace.array(CodexExperimentalFeatureSchema).optional(),
2076
+ skills: z__namespace.array(CodexSkillSummarySchema).optional(),
2077
+ prompts: z__namespace.array(CodexPromptSummarySchema).optional(),
2078
+ agents: z__namespace.array(CodexAgentSummarySchema).optional(),
2079
+ mcpServers: z__namespace.array(CodexMcpServerSummarySchema).optional()
2080
+ });
2081
+
1731
2082
  exports.AGENT_MSG_PRIORITIES = AGENT_MSG_PRIORITIES;
1732
2083
  exports.AGENT_MSG_STATUSES = AGENT_MSG_STATUSES;
1733
2084
  exports.AGENT_MSG_TYPES = AGENT_MSG_TYPES;
@@ -1760,9 +2111,25 @@ exports.BUILT_IN_AI_BACKEND_PROFILE_IDS = BUILT_IN_AI_BACKEND_PROFILE_IDS;
1760
2111
  exports.BootstrapProfileSummarySchema = BootstrapProfileSummarySchema;
1761
2112
  exports.BriefMessageSchema = BriefMessageSchema;
1762
2113
  exports.BuiltInAIBackendProfileIdSchema = BuiltInAIBackendProfileIdSchema;
2114
+ exports.CODEX_APP_SERVER_BACKEND = CODEX_APP_SERVER_BACKEND;
2115
+ exports.CODEX_MCP_LEGACY_BACKEND = CODEX_MCP_LEGACY_BACKEND;
2116
+ exports.CODEX_REQUESTED_BACKEND_ALIASES = CODEX_REQUESTED_BACKEND_ALIASES;
1763
2117
  exports.CliInstallInfoSchema = CliInstallInfoSchema;
1764
2118
  exports.CliInstallSourceSchema = CliInstallSourceSchema;
2119
+ exports.CodexAccountSchema = CodexAccountSchema;
2120
+ exports.CodexAgentSummarySchema = CodexAgentSummarySchema;
2121
+ exports.CodexBackendModeSchema = CodexBackendModeSchema;
2122
+ exports.CodexConfigModeSchema = CodexConfigModeSchema;
1765
2123
  exports.CodexConfigSchema = CodexConfigSchema;
2124
+ exports.CodexExperimentalFeatureSchema = CodexExperimentalFeatureSchema;
2125
+ exports.CodexMcpServerSummarySchema = CodexMcpServerSummarySchema;
2126
+ exports.CodexMetadataSchema = CodexMetadataSchema;
2127
+ exports.CodexPromptSummarySchema = CodexPromptSummarySchema;
2128
+ exports.CodexRateLimitsSchema = CodexRateLimitsSchema;
2129
+ exports.CodexRequestedBackendSchema = CodexRequestedBackendSchema;
2130
+ exports.CodexResolvedBackendSchema = CodexResolvedBackendSchema;
2131
+ exports.CodexRuntimeConfigSchema = CodexRuntimeConfigSchema;
2132
+ exports.CodexSkillSummarySchema = CodexSkillSummarySchema;
1766
2133
  exports.CoreUpdateBodySchema = CoreUpdateBodySchema;
1767
2134
  exports.CoreUpdateContainerSchema = CoreUpdateContainerSchema;
1768
2135
  exports.CreateKnowledgeEntryBodySchema = CreateKnowledgeEntryBodySchema;
@@ -1866,16 +2233,22 @@ exports.WorldAutonomyPolicySchema = WorldAutonomyPolicySchema;
1866
2233
  exports.WorldSuggestionUpdatedSchema = WorldSuggestionUpdatedSchema;
1867
2234
  exports.createEnvelope = createEnvelope;
1868
2235
  exports.createResolvedRuntimeProfile = createResolvedRuntimeProfile;
2236
+ exports.getBuiltInAIBackendProfile = getBuiltInAIBackendProfile;
1869
2237
  exports.getHappyMcpToolAction = getHappyMcpToolAction;
1870
2238
  exports.getHappyMcpToolAliases = getHappyMcpToolAliases;
1871
2239
  exports.getHappyMcpToolTitle = getHappyMcpToolTitle;
1872
2240
  exports.getProfileEnvironmentVariables = getProfileEnvironmentVariables;
1873
2241
  exports.getSuggestionPayloadSchema = getSuggestionPayloadSchema;
2242
+ exports.isCodexAppServerBackend = isCodexAppServerBackend;
2243
+ exports.isCodexLegacyBackend = isCodexLegacyBackend;
1874
2244
  exports.isHappyMcpToolAlias = isHappyMcpToolAlias;
1875
2245
  exports.isHappyMcpToolName = isHappyMcpToolName;
1876
2246
  exports.isTrustedRuntimeProfile = isTrustedRuntimeProfile;
1877
2247
  exports.normalizeHappyMcpToolName = normalizeHappyMcpToolName;
1878
2248
  exports.normalizeResolvedRuntimeProfile = normalizeResolvedRuntimeProfile;
2249
+ exports.resolveCodexResolvedBackend = resolveCodexResolvedBackend;
2250
+ exports.resolveCodexResumableThreadId = resolveCodexResumableThreadId;
2251
+ exports.resolveRequestedCodexBackend = resolveRequestedCodexBackend;
1879
2252
  exports.sessionContextUsageCategorySchema = sessionContextUsageCategorySchema;
1880
2253
  exports.sessionContextUsageEventSchema = sessionContextUsageEventSchema;
1881
2254
  exports.sessionEnvelopeSchema = sessionEnvelopeSchema;