@codemem/server 0.46.0 → 0.46.2

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.d.ts CHANGED
@@ -12,6 +12,7 @@ import { MemoryStore, type RawEventSweeper, VERSION } from "@codemem/core";
12
12
  import { Hono } from "hono";
13
13
  import type { RawEventInbox } from "./raw-event-inbox.js";
14
14
  import { type InMemoryRequestRateLimiter } from "./request-rate-limit.js";
15
+ import { type ConfigRouteOptions } from "./routes/config.js";
15
16
  import { type SyncRoutesOptions } from "./routes/sync.js";
16
17
  import { type ViewerTargetStore } from "./routes/target-validation.js";
17
18
  import { type LegacyTeamCompletionDependencies, type LegacyTeamConfiguredGroupSnapshotLoader } from "./routes/team-setup.js";
@@ -37,6 +38,9 @@ export interface AppOptions {
37
38
  rawEventTarget?: ViewerTargetStore;
38
39
  sweeper?: RawEventSweeper | null;
39
40
  observer?: ObserverClient | null;
41
+ getObserver?: () => ObserverClient | null;
42
+ scheduleObserverApply?: ConfigRouteOptions["scheduleObserverApply"];
43
+ getObserverApplyStatus?: ConfigRouteOptions["getObserverApplyStatus"];
40
44
  getUpdateStatus?: (options: GetUpdateStatusOptions) => Promise<UpdateStatus>;
41
45
  loadDeviceIdentityCoordinatorEvidence?: () => Promise<DeviceIdentityCoordinatorEvidence>;
42
46
  loadLegacyTeamConfiguredGroupSnapshots?: LegacyTeamConfiguredGroupSnapshotLoader;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,KAAK,EACX,iCAAiC,EACjC,sBAAsB,EACtB,cAAc,EACd,YAAY,EACZ,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,WAAW,EAAE,KAAK,eAAe,EAAiB,OAAO,EAAE,MAAM,eAAe,CAAC;AAE1F,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,OAAO,KAA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AAE,0BAA0B,CAAC;QACrC,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,wBAAwB,CAAC,EAAE,MAAM,CAAC;QAClC,4BAA4B,CAAC,EAAE,MAAM,CAAC;KACtC,CAAC;IACF,oBAAoB,CAAC,EAAE,MAAM;QAC5B,KAAK,EACF,UAAU,GACV,SAAS,GACT,UAAU,GACV,OAAO,GACP,UAAU,GACV,iBAAiB,GACjB,iBAAiB,GACjB,IAAI,CAAC;QACR,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;KACvB,GAAG,IAAI,CAAC;CACT;AAkDD,wBAAgB,SAAS,CAAC,IAAI,CAAC,EAAE,UAAU,8EA8D1C;AAED;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,IAAI,CAAC,EAAE,UAAU,8EA8B9C"}
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { existsSync, readFileSync } from "node:fs";
2
2
  import { dirname, isAbsolute, join, posix, resolve, win32 } from "node:path";
3
- import { ACCESS_CLEANUP_OP_TYPE, CodememConfigMutationError, CoordinatorReciprocalApprovalRequestChangedError, DEFAULT_TIME_WINDOW_S, LEGACY_SHARED_REVIEW_SCOPE_ID, LOCAL_DEFAULT_SCOPE_ID, LOCAL_SYNC_CAPABILITY, LOCAL_SYNC_FEATURES, LegacyTeamSetupAdditiveConvergenceError, LegacyTeamSetupRosterCapacityError, MEMORY_FILTER_FIELD_TYPES, MEMORY_FILTER_NAMES, MEMORY_KIND_DESCRIPTIONS, MemoryStore, ObserverClient, PROMPT_TRANSPORT_PROTOCOL_RANGE, REMEMBER_MEMORY_KINDS, RawEventIngestValidationError, RecipientPolicyEdgeRequestError, RecipientPolicyTeamRenameError, RemoteCoordinatorRequestError, SCOPE_MEMBERSHIP_REVOCATION_LIMITATION, SYNC_AUTHORIZATION_REFRESH_HEADER, SYNC_CAPABILITY_HEADER, SYNC_FEATURES_HEADER, SYNC_SCOPE_QUERY_PARAM, VERSION, VERSION as VERSION$1, VIEWER_IDENTITY_TARGET_KEYS, VIEWER_SERVICE_DISCRIMINATOR, addSyncScopeToBoundary, analyzeProjectScopeMappingChangeGuardrails, analyzeProjectScopeMappingChangesGuardrails, analyzeProjectScopeMappingDeletionGuardrails, applyLegacyTeamSetupCompletionManifest, applyLegacyTeamSetupCompletionManifestAndReturnActivation, applyReplicationOps, areLegacyTeamSetupCompletionPolicyFactsAdditivelyCompatible, automaticRecallHealth, buildAuthHeaders, buildBaseUrl, buildDirectPeerAuthHeaders, buildDistillReport, buildFilterClausesWithContext, buildPiFlushSignalFromEvent, buildRawEventEnvelopeFromCodexHook, buildRawEventEnvelopeFromHook, buildRawEventEnvelopeFromPiEvent, buildViewerIdentityTarget, canonicalCoordinatorLegacyTeamCompletionManifestJson, canonicalMemoryKind, canonicalRepositoryProjectIdentity, canonicalWorkspaceIdentity, claimRecipientPolicyActorMutations, claimRecipientPolicyPublicationMutation, classifyRecordedSyncFailure, cleanupNonces, clearLegacyTeamSetupDeviceDecision, clonePromptPackAttempt, coerceObserverCommand, commitDeviceIdentityBindings, commitRecipientPolicyEdges, containLegacyTeamSetupCompletionConflict, coordinatorArchiveGroupAction, coordinatorCreateAddDeviceInviteAction, coordinatorCreateGroupAction, coordinatorCreateInviteAction, coordinatorCreateLegacyTeamCompletionAction, coordinatorCreateScopeAction, coordinatorDisableDeviceAction, coordinatorEnableDeviceAction, coordinatorGetLegacyTeamCompletionAction, coordinatorGrantScopeMembershipAction, coordinatorImportInviteAction, coordinatorListBootstrapGrantsAction, coordinatorListConsumedTeamInvitesAction, coordinatorListDevicesAction, coordinatorListGroupsAction, coordinatorListJoinRequestsAction, coordinatorListLegacyTeamCompletionsAction, coordinatorListReviewedRecipientInviteEvidenceAction, coordinatorListScopeMembershipsAction, coordinatorListScopesAction, coordinatorRemoveDeviceAction, coordinatorRenameDeviceAction, coordinatorRenameGroupAction, coordinatorReviewJoinRequestAction, coordinatorRevokeBootstrapGrantAction, coordinatorRevokeScopeMembershipAction, coordinatorStatusSnapshot, coordinatorUnarchiveGroupAction, coordinatorUpdateScopeAction, countShareableProjectMemories, createCoordinatorReciprocalApproval, decodeInvitePayload, dedupeOrderedIds, defaultSpaceScopeIdForGroup, deleteProjectScopeSettingsMapping, deriveLegacyTeamSetupCompletionManifest, detectInstallKind, deterministicPolicyTeamId, diagnoseStalePeerReceivedRows, discoverLegacyTeamCandidates, ensureDeviceIdentity, executeShareProvisioning, extractInvitePayload, extractReplicationOps, filterReplicationOpsForSyncWithStatus, fingerprintPublicKey, formatHostPort, friendlyDeviceName, fromJson, getCodememConfigPath, getCodememEnvOverrideValues, getCodememEnvOverrides, getCoordinatorEnrollmentReconciliationIssueSummary, getCoordinatorGroupPreference, getLegacyTeamSetupDraft, getRecipientPolicyAuthorityState, getSemanticIndexDiagnostics, getSyncResetState, getUpdateStatus, ingestRawEvents, inspectFreshLegacyTeamSetupActivation, inspectLegacyTeamSetupActivation, inviteTokenDigest, isAutomaticRecallMeasurement, isLegacyTeamCandidateSelectable, isLegacyTeamSetupProjectMappingIdentity, isPeerTrustBindingCompatible, isProjectSyncEnablementError, isScopedSyncCapability, judgeDistillReport, legacyTeamCandidateId, legacyTeamCandidateProjectInventory, legacyTeamCanonicalProjectRef, legacyTeamDeviceRef, legacyTeamResolvedProjectRef, legacyTeamSetupApiErrorCode, listAuthorizedScopesForPeer, listCoordinatorJoinRequests, listDeviceIdentityInventory, listInboundScopeRejections, listLegacyRecipientPolicyProjections, listMaintenanceJobs, listObserverProviderOptions, listPerPeerScopeSyncState, listProjectScopeCandidates, listProjectScopeInventory, listProjectScopeSettingsMappings, listRecipientPolicyIntent, listRecipientPolicyReview, listSharingDomainSettingsScopes, loadMemorySnapshotPageForPeer, loadReplicationOpsForPeer, lookupCoordinatorPeers, memoryFilterValueMatchesType, mergeAddresses, migrateRecipientPolicyIntent, mutateCodememConfigFile, negotiateSyncCapability, normalizeAddress, normalizeHumanPresentationName, normalizeSyncCapability, normalizeSyncFeatures, normalizeTeammateName, parseAcceptedProjectIntent, parsePositiveMemoryId, parseReassignScopePayload, parseRecipientPolicyEdgeCommitRequest, parseStrictInteger, parseSyncScopeRequest, persistShareOperation, personalScopeGrantStatusForPeer, planShareOperation, previewDeviceIdentityBindings, previewLegacyTeamSetupActivation, previewRecipientPolicyEdges, previewRecipientPolicyOnboarding, previewRecipientPolicyOnboardingFromReviewedIntent, probeAvailableCredentials, projectMatchesFilter, projectShareLifecycle, promptPackArtifactFingerprint, readCodememConfigFile, readCoordinatorSyncConfig, reassignProjectScopeInventoryProject, recipientInviteAuthoritativeIdentityId, recipientPolicyDigest, recipientReviewedIntentDigest, reconcileCoordinatorEnrollmentSnapshot, reconcileRecipientPolicyProject, reconcileShareOperationAcceptance, reconstructLegacyTeamSetupCompletionManifest, recordAutomaticRecall, recordHighestObservedDirectSignatureVersion, recordNonce, recordPromptPackArtifacts, recordPromptPackTerminal, refreshAuthorizedCoordinatorPeerTrust, refreshConfiguredScopeMembershipCache, refreshLegacyTeamCandidate, rejectInboundScopeFailures, renameRecipientPolicyTeam, replayLegacyTeamSetupActivation, repositoryIdentitiesByWorkspace, repositoryIdentityForWorkspace, requestJson, requireLegacyTeamSetupAccessDeltaWithinLimit, resolveDbPath, resolveObserverRuntime, resolveProject, resolveProjectRoot, resolveRecipientPolicyReview, resolveRecipientPolicyReviewBulk, runSyncPass, schema, serializeRecipientPolicyCoordinatorGroupMutation, serializeRecipientPolicyPublicationMutation, serializeRecipientPolicyTeamMutation, setLegacyTeamSetupDeviceAssignment, setLegacyTeamSetupDeviceDecision, setLegacyTeamSetupProjectMapping, storeVectors, summarizeInboundScopeRejections, summaryLikeSqlPredicate, supportsSyncFeature, syncScopeResetRequiredPayload, toJson, tryUpdateRetrievalDelivery, updatePeerAddresses, upsertCoordinatorGroupPreference, upsertProjectScopeSettingsMappings, validateLegacyTeamSetupCompletionManifest, validateLegacyTeamSetupCompletionManifestBinding, validateRawEvents, verifyDirectPeerSignature, verifyRecipientReviewedIntent, verifySignature, wakeRecipientPoliciesForIdentities, wakeRecipientPoliciesForProjectIdentities } from "@codemem/core";
3
+ import { ACCESS_CLEANUP_OP_TYPE, CodememConfigMutationError, CoordinatorReciprocalApprovalRequestChangedError, DEFAULT_TIME_WINDOW_S, LEGACY_SHARED_REVIEW_SCOPE_ID, LOCAL_DEFAULT_SCOPE_ID, LOCAL_SYNC_CAPABILITY, LOCAL_SYNC_FEATURES, LegacyTeamSetupAdditiveConvergenceError, LegacyTeamSetupRosterCapacityError, MEMORY_FILTER_FIELD_TYPES, MEMORY_FILTER_NAMES, MEMORY_KIND_DESCRIPTIONS, MemoryStore, ObserverClient, PROMPT_TRANSPORT_PROTOCOL_RANGE, REMEMBER_MEMORY_KINDS, RICH_TIER_ANTHROPIC_DEFAULTS, RICH_TIER_DEFAULTS, RawEventIngestValidationError, RecipientPolicyEdgeRequestError, RecipientPolicyTeamRenameError, RemoteCoordinatorRequestError, SCOPE_MEMBERSHIP_REVOCATION_LIMITATION, SIMPLE_TIER_ANTHROPIC_DEFAULTS, SIMPLE_TIER_DEFAULTS, SYNC_AUTHORIZATION_REFRESH_HEADER, SYNC_CAPABILITY_HEADER, SYNC_FEATURES_HEADER, SYNC_SCOPE_QUERY_PARAM, VERSION, VERSION as VERSION$1, VIEWER_IDENTITY_TARGET_KEYS, VIEWER_SERVICE_DISCRIMINATOR, addSyncScopeToBoundary, analyzeProjectScopeMappingChangeGuardrails, analyzeProjectScopeMappingChangesGuardrails, analyzeProjectScopeMappingDeletionGuardrails, applyLegacyTeamSetupCompletionManifest, applyLegacyTeamSetupCompletionManifestAndReturnActivation, applyReplicationOps, areLegacyTeamSetupCompletionPolicyFactsAdditivelyCompatible, automaticRecallHealth, buildAuthHeaders, buildBaseUrl, buildDirectPeerAuthHeaders, buildDistillReport, buildFilterClausesWithContext, buildPiFlushSignalFromEvent, buildRawEventEnvelopeFromCodexHook, buildRawEventEnvelopeFromHook, buildRawEventEnvelopeFromPiEvent, buildViewerIdentityTarget, canonicalCoordinatorLegacyTeamCompletionManifestJson, canonicalMemoryKind, canonicalRepositoryProjectIdentity, canonicalWorkspaceIdentity, claimRecipientPolicyActorMutations, claimRecipientPolicyPublicationMutation, classifyRecordedSyncFailure, cleanupNonces, clearLegacyTeamSetupDeviceDecision, clonePromptPackAttempt, coerceObserverCommand, commitDeviceIdentityBindings, commitRecipientPolicyEdges, containLegacyTeamSetupCompletionConflict, coordinatorArchiveGroupAction, coordinatorCreateAddDeviceInviteAction, coordinatorCreateGroupAction, coordinatorCreateInviteAction, coordinatorCreateLegacyTeamCompletionAction, coordinatorCreateScopeAction, coordinatorDisableDeviceAction, coordinatorEnableDeviceAction, coordinatorGetLegacyTeamCompletionAction, coordinatorGrantScopeMembershipAction, coordinatorImportInviteAction, coordinatorListBootstrapGrantsAction, coordinatorListConsumedTeamInvitesAction, coordinatorListDevicesAction, coordinatorListGroupsAction, coordinatorListJoinRequestsAction, coordinatorListLegacyTeamCompletionsAction, coordinatorListReviewedRecipientInviteEvidenceAction, coordinatorListScopeMembershipsAction, coordinatorListScopesAction, coordinatorRemoveDeviceAction, coordinatorRenameDeviceAction, coordinatorRenameGroupAction, coordinatorReviewJoinRequestAction, coordinatorRevokeBootstrapGrantAction, coordinatorRevokeScopeMembershipAction, coordinatorStatusSnapshot, coordinatorUnarchiveGroupAction, coordinatorUpdateScopeAction, countShareableProjectMemories, createCoordinatorReciprocalApproval, decodeInvitePayload, dedupeOrderedIds, defaultSpaceScopeIdForGroup, deleteProjectScopeSettingsMapping, deriveLegacyTeamSetupCompletionManifest, detectInstallKind, deterministicPolicyTeamId, diagnoseStalePeerReceivedRows, discoverLegacyTeamCandidates, ensureDeviceIdentity, executeShareProvisioning, extractInvitePayload, extractReplicationOps, filterReplicationOpsForSyncWithStatus, fingerprintPublicKey, formatHostPort, friendlyDeviceName, fromJson, generateWithOpenCodeV2, getCodememConfigPath, getCodememEnvOverrideValues, getCodememEnvOverrides, getCoordinatorEnrollmentReconciliationIssueSummary, getCoordinatorGroupPreference, getLegacyTeamSetupDraft, getRecipientPolicyAuthorityState, getSemanticIndexDiagnostics, getSyncResetState, getUpdateStatus, ingestRawEvents, inspectFreshLegacyTeamSetupActivation, inspectLegacyTeamSetupActivation, inviteTokenDigest, isAutomaticRecallMeasurement, isLegacyTeamCandidateSelectable, isLegacyTeamSetupProjectMappingIdentity, isPeerTrustBindingCompatible, isProjectSyncEnablementError, isScopedSyncCapability, judgeDistillReport, legacyTeamCandidateId, legacyTeamCandidateProjectInventory, legacyTeamCanonicalProjectRef, legacyTeamDeviceRef, legacyTeamResolvedProjectRef, legacyTeamSetupApiErrorCode, listAuthorizedScopesForPeer, listCoordinatorJoinRequests, listDeviceIdentityInventory, listInboundScopeRejections, listLegacyRecipientPolicyProjections, listMaintenanceJobs, listObserverProviderOptions, listOpenCodeV2Models, listPerPeerScopeSyncState, listProjectScopeCandidates, listProjectScopeInventory, listProjectScopeSettingsMappings, listRecipientPolicyIntent, listRecipientPolicyReview, listSharingDomainSettingsScopes, loadMemorySnapshotPageForPeer, loadReplicationOpsForPeer, lookupCoordinatorPeers, memoryFilterValueMatchesType, mergeAddresses, migrateRecipientPolicyIntent, mutateCodememConfigFile, negotiateSyncCapability, normalizeAddress, normalizeHumanPresentationName, normalizeSyncCapability, normalizeSyncFeatures, normalizeTeammateName, parseAcceptedProjectIntent, parsePositiveMemoryId, parseReassignScopePayload, parseRecipientPolicyEdgeCommitRequest, parseStrictInteger, parseSyncScopeRequest, persistShareOperation, personalScopeGrantStatusForPeer, planShareOperation, previewDeviceIdentityBindings, previewLegacyTeamSetupActivation, previewRecipientPolicyEdges, previewRecipientPolicyOnboarding, previewRecipientPolicyOnboardingFromReviewedIntent, probeAvailableCredentials, projectMatchesFilter, projectShareLifecycle, promptPackArtifactFingerprint, readCodememConfigFile, readCoordinatorSyncConfig, reassignProjectScopeInventoryProject, recipientInviteAuthoritativeIdentityId, recipientPolicyDigest, recipientReviewedIntentDigest, reconcileCoordinatorEnrollmentSnapshot, reconcileRecipientPolicyProject, reconcileShareOperationAcceptance, reconstructLegacyTeamSetupCompletionManifest, recordAutomaticRecall, recordHighestObservedDirectSignatureVersion, recordNonce, recordPromptPackArtifacts, recordPromptPackTerminal, refreshAuthorizedCoordinatorPeerTrust, refreshConfiguredScopeMembershipCache, refreshLegacyTeamCandidate, rejectInboundScopeFailures, renameRecipientPolicyTeam, replayLegacyTeamSetupActivation, repositoryIdentitiesByWorkspace, repositoryIdentityForWorkspace, requestJson, requireLegacyTeamSetupAccessDeltaWithinLimit, resolveDbPath, resolveObserverDefaultModel, resolveObserverRuntime, resolveProject, resolveProjectRoot, resolveRecipientPolicyReview, resolveRecipientPolicyReviewBulk, runSyncPass, schema, serializeRecipientPolicyCoordinatorGroupMutation, serializeRecipientPolicyPublicationMutation, serializeRecipientPolicyTeamMutation, setLegacyTeamSetupDeviceAssignment, setLegacyTeamSetupDeviceDecision, setLegacyTeamSetupProjectMapping, storeVectors, summarizeInboundScopeRejections, summaryLikeSqlPredicate, supportsSyncFeature, syncScopeResetRequiredPayload, toJson, tryUpdateRetrievalDelivery, updatePeerAddresses, upsertCoordinatorGroupPreference, upsertProjectScopeSettingsMappings, validateLegacyTeamSetupCompletionManifest, validateLegacyTeamSetupCompletionManifestBinding, validateRawEvents, verifyDirectPeerSignature, verifyRecipientReviewedIntent, verifySignature, wakeRecipientPoliciesForIdentities, wakeRecipientPoliciesForProjectIdentities } from "@codemem/core";
4
4
  import { serveStatic } from "@hono/node-server/serve-static";
5
5
  import { Hono } from "hono";
6
6
  import { createMiddleware } from "hono/factory";
@@ -171,6 +171,8 @@ function createInMemoryRequestRateLimiter(windowMs = 6e4) {
171
171
  var REDACTED_VALUE = "[redacted]";
172
172
  var RUNTIMES = /* @__PURE__ */ new Set([
173
173
  "api_http",
174
+ "api_key",
175
+ "opencode_v2",
174
176
  "claude_sidecar",
175
177
  "codex_sidecar"
176
178
  ]);
@@ -182,6 +184,7 @@ var AUTH_SOURCES = /* @__PURE__ */ new Set([
182
184
  "none"
183
185
  ]);
184
186
  var HOT_RELOAD_KEYS = /* @__PURE__ */ new Set(["raw_events_sweeper_interval_s"]);
187
+ var NO_RUNTIME_EFFECT_KEYS = /* @__PURE__ */ new Set(["pack_observation_limit", "pack_session_limit"]);
185
188
  var EXECUTABLE_ARGV_KEYS = /* @__PURE__ */ new Set([
186
189
  "claude_command",
187
190
  "codex_command",
@@ -264,6 +267,7 @@ var ALLOWED_KEYS = [
264
267
  "sync_coordinator_presence_ttl_s",
265
268
  "raw_events_sweeper_interval_s"
266
269
  ];
270
+ var OBSERVER_KEYS = new Set(ALLOWED_KEYS.filter((key) => key.startsWith("observer_") || key === "codex_command" || key === "claude_command"));
267
271
  var DEFAULTS = {
268
272
  claude_command: ["claude"],
269
273
  codex_command: ["codex"],
@@ -292,6 +296,27 @@ var DEFAULTS = {
292
296
  function loadProviderOptions() {
293
297
  return listObserverProviderOptions();
294
298
  }
299
+ function modelDefaultMetadata() {
300
+ return {
301
+ base: Object.fromEntries(loadProviderOptions().map((provider) => [provider, resolveObserverDefaultModel("api_key", provider)])),
302
+ claude: resolveObserverDefaultModel("claude_sidecar", "anthropic"),
303
+ codex: resolveObserverDefaultModel("codex_sidecar", "openai"),
304
+ simple: {
305
+ openai: SIMPLE_TIER_DEFAULTS.observerModel,
306
+ anthropic: SIMPLE_TIER_ANTHROPIC_DEFAULTS.observerModel
307
+ },
308
+ rich: {
309
+ openai: RICH_TIER_DEFAULTS.observerModel,
310
+ anthropic: RICH_TIER_ANTHROPIC_DEFAULTS.observerModel
311
+ }
312
+ };
313
+ }
314
+ function settingsCapabilityMetadata(opts) {
315
+ return {
316
+ observer_model_defaults: modelDefaultMetadata(),
317
+ restart_required_keys: ALLOWED_KEYS.filter((key) => !NO_RUNTIME_EFFECT_KEYS.has(key) && !HOT_RELOAD_KEYS.has(key) && !(OBSERVER_KEYS.has(key) && opts.scheduleObserverApply))
318
+ };
319
+ }
295
320
  function withoutRemovedConfigKeys(configData) {
296
321
  const next = { ...configData };
297
322
  for (const key of REMOVED_CONFIG_KEYS) delete next[key];
@@ -307,8 +332,18 @@ function getEffectiveConfig(configData) {
307
332
  return effective;
308
333
  }
309
334
  function observerRuntimeMetadata(configData) {
335
+ const automatic = { ...configData };
336
+ delete automatic.observer_runtime;
310
337
  return {
311
338
  resolved_observer_runtime: resolveObserverRuntime(configData),
339
+ observer_runtime_after_auth_override_removal: Object.fromEntries([...AUTH_SOURCES].map((source) => [source, resolveObserverRuntime({
340
+ ...automatic,
341
+ observer_auth_source: source
342
+ }, { ignoreAuthSourceOverride: true })])),
343
+ observer_automatic_runtime_by_auth_source: Object.fromEntries([...AUTH_SOURCES].map((source) => [source, resolveObserverRuntime({
344
+ ...automatic,
345
+ observer_auth_source: source
346
+ })])),
312
347
  observer_runtime_by_auth_source: Object.fromEntries([...AUTH_SOURCES].map((source) => [source, resolveObserverRuntime({
313
348
  ...configData,
314
349
  observer_auth_source: source
@@ -404,7 +439,7 @@ function applyObserverProvider(configData, value, providers) {
404
439
  function applyNormalizedEnum(configData, key, value, allowed) {
405
440
  if (typeof value !== "string") return `${key} must be string`;
406
441
  const normalized = value.trim().toLowerCase();
407
- if (!allowed.has(normalized)) return `${key} must be one of: ${key === "observer_runtime" ? "api_http, claude_sidecar, codex_sidecar" : "auto, env, file, command, none"}`;
442
+ if (!allowed.has(normalized)) return `${key} must be one of: ${key === "observer_runtime" ? "api_http, api_key, opencode_v2, claude_sidecar, codex_sidecar" : "auto, env, file, command, none"}`;
408
443
  configData[key] = normalized;
409
444
  return null;
410
445
  }
@@ -530,17 +565,21 @@ function viewerConfigSavePayload(saved, opts) {
530
565
  ...savedChangedKeys,
531
566
  ...effectiveChangedKeys
532
567
  ])];
568
+ const observerChangedKeys = [.../* @__PURE__ */ new Set([...effectiveChangedKeys, ...savedChangedKeys.filter((key) => !(key in envOverrides))])].filter((key) => OBSERVER_KEYS.has(key));
569
+ const applyingKeys = observerChangedKeys.length > 0 && opts.scheduleObserverApply?.() === true ? observerChangedKeys : [];
533
570
  return {
534
571
  path: savedPath,
535
572
  config: sanitizeConfigForResponse(nextConfig),
536
573
  effective: sanitizeConfigForResponse(afterEffective),
537
574
  ...observerRuntimeMetadata(nextConfig),
575
+ ...opts.getObserverApplyStatus ? { observer_apply: opts.getObserverApplyStatus() } : {},
538
576
  protected_keys: [...PROTECTED_WRITE_KEYS].sort(),
539
577
  effects: {
540
578
  saved_keys: savedChangedKeys,
541
579
  effective_keys: effectiveChangedKeys,
542
580
  hot_reloaded_keys: applyRuntimeEffects(runtimeChangedKeys, opts),
543
- restart_required_keys: effectiveChangedKeys.filter((key) => !HOT_RELOAD_KEYS.has(key) && !(key in envOverrides)),
581
+ applying_keys: applyingKeys,
582
+ restart_required_keys: [.../* @__PURE__ */ new Set([...effectiveChangedKeys, ...observerChangedKeys])].filter((key) => !NO_RUNTIME_EFFECT_KEYS.has(key) && !HOT_RELOAD_KEYS.has(key) && !applyingKeys.includes(key) && !(key in envOverrides)),
544
583
  ignored_by_env_keys: ignoredByEnvKeys,
545
584
  warnings: ignoredByEnvKeys.map((key) => `${key} is currently controlled by ${envOverrides[key]}; saved config will not take effect until that override is removed.`)
546
585
  }
@@ -559,6 +598,40 @@ async function handleConfigPost(c, opts) {
559
598
  }
560
599
  function configRoutes(opts = {}) {
561
600
  const app = new Hono();
601
+ const modelChecks = createInMemoryRequestRateLimiter();
602
+ app.get("/api/observer-model-catalog", async (c) => {
603
+ return c.json({
604
+ models: await listOpenCodeV2Models(),
605
+ availability: "catalog_only"
606
+ });
607
+ });
608
+ app.post("/api/observer-model-check", async (c) => {
609
+ let input;
610
+ try {
611
+ input = await c.req.json();
612
+ } catch {
613
+ return c.json({ error: "Choose a provider and model to check." }, 400);
614
+ }
615
+ if (!input || typeof input !== "object") return c.json({ error: "Choose a provider and model to check." }, 400);
616
+ const { provider, model } = input;
617
+ if (provider !== "openai" && provider !== "anthropic" || typeof model !== "string" || !/^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/.test(model)) return c.json({ error: "Choose an OpenAI or Anthropic model to check." }, 400);
618
+ const check = modelChecks.check("observer-model-check", 2);
619
+ if (!check.allowed) {
620
+ c.header("Retry-After", String(check.retryAfterS));
621
+ return c.json({ error: "Model checks are limited. Try again shortly." }, 429);
622
+ }
623
+ const result = await generateWithOpenCodeV2({
624
+ provider,
625
+ model,
626
+ prompt: "Reply exactly OK."
627
+ });
628
+ return c.json({
629
+ provider,
630
+ model,
631
+ available: result.error === null && result.text?.trim() === "OK",
632
+ status: result.error ?? (result.text?.trim() === "OK" ? "verified" : "unexpected_response")
633
+ });
634
+ });
562
635
  app.get("/api/config", (c) => {
563
636
  const configPath = getCodememConfigPath();
564
637
  const configData = withoutRemovedConfigKeys(readCodememConfigFile());
@@ -569,12 +642,18 @@ function configRoutes(opts = {}) {
569
642
  defaults: DEFAULTS,
570
643
  effective: sanitizeConfigForResponse(effective),
571
644
  ...observerRuntimeMetadata(configData),
645
+ ...opts.getObserverApplyStatus ? { observer_apply: opts.getObserverApplyStatus() } : {},
572
646
  env_overrides: getCodememEnvOverrides(),
573
647
  protected_keys: [...PROTECTED_WRITE_KEYS].sort(),
574
- providers: loadProviderOptions()
648
+ providers: loadProviderOptions(),
649
+ ...settingsCapabilityMetadata(opts)
575
650
  });
576
651
  });
577
652
  app.post("/api/config", (c) => handleConfigPost(c, opts));
653
+ app.post("/api/config/apply-observer", (c) => {
654
+ if (opts.scheduleObserverApply?.() !== true) return c.json({ error: "Observer settings could not be applied. Restart the viewer." }, 409);
655
+ return c.json({ observer_apply: opts.getObserverApplyStatus?.() ?? { state: "applying" } });
656
+ });
578
657
  return app;
579
658
  }
580
659
  //#endregion
@@ -12504,10 +12583,17 @@ function registerStaticRoutes(app) {
12504
12583
  return c.html(indexHtml);
12505
12584
  });
12506
12585
  }
12586
+ function registerConfigRoutes(app, opts, sweeper) {
12587
+ app.route("/", configRoutes({
12588
+ getSweeper: () => sweeper,
12589
+ scheduleObserverApply: opts?.scheduleObserverApply,
12590
+ getObserverApplyStatus: opts?.getObserverApplyStatus
12591
+ }));
12592
+ }
12507
12593
  function createApp(opts) {
12508
12594
  const storeFactory = opts?.storeFactory ?? getStore;
12509
12595
  const sweeper = opts?.sweeper ?? null;
12510
- const observer = opts?.observer ?? null;
12596
+ const getObserver = opts?.getObserver ?? (() => opts?.observer ?? null);
12511
12597
  const getSyncRuntimeStatus = opts?.getSyncRuntimeStatus ?? (() => null);
12512
12598
  let invalidateTeamSetupSummary = () => {};
12513
12599
  const app = new Hono();
@@ -12525,9 +12611,9 @@ function createApp(opts) {
12525
12611
  app.route("/", observerStatusRoutes({
12526
12612
  getStore: storeFactory,
12527
12613
  getSweeper: () => sweeper,
12528
- getObserver: () => observer
12614
+ getObserver
12529
12615
  }));
12530
- app.route("/", configRoutes({ getSweeper: () => sweeper }));
12616
+ registerConfigRoutes(app, opts, sweeper);
12531
12617
  app.route("/", rawEventsRoutes(storeFactory, sweeper, opts?.rawEventInbox, opts?.rawEventTarget));
12532
12618
  app.route("/", syncRoutes(storeFactory, getSyncRuntimeStatus, {
12533
12619
  loadDeviceIdentityCoordinatorEvidence: opts?.loadDeviceIdentityCoordinatorEvidence,