diff --git a/packages/core/src/void-self-state-domain.ts b/packages/core/src/void-self-state-domain.ts index 855cf49..4705bd7 100644 --- a/packages/core/src/void-self-state-domain.ts +++ b/packages/core/src/void-self-state-domain.ts @@ -115,6 +115,7 @@ const distilledMemorySchema = z.object({ updatedAt: timestampSchema, retiredAt: timestampSchema.optional(), tags: z.array(nonEmptyStringSchema).default([]), + semanticIndex: z.unknown().optional(), }).strict(); const meaningPreservingMemorySchema = distilledMemorySchema.superRefine((memory, context) => { diff --git a/scripts/run-repo-face-heartbeats.ts b/scripts/run-repo-face-heartbeats.ts index 2e31158..e642d42 100644 --- a/scripts/run-repo-face-heartbeats.ts +++ b/scripts/run-repo-face-heartbeats.ts @@ -1946,7 +1946,13 @@ async function renderRepoFaceMemorySurfaceForTurn( humanPronounGuidance?: RepoFaceHumanPronounGuidance[], ): Promise { if (identity.identityKind === "native_persona") { - return renderNativePersonaMemorySurface(identity); + return renderNativePersonaMemorySurface( + identity, + config, + registryIdentities, + roomContext, + humanPronounGuidance ?? await loadRepoFaceHumanPronounGuidance(config, roomContext), + ); } const statePath = resolveRepoFaceStatePath(identity, config.storageRoot); @@ -1973,7 +1979,16 @@ async function renderRepoFaceMemorySurfaceForTurn( }); } -async function renderNativePersonaMemorySurface(identity: RepoDiscordIdentity): Promise { +async function renderNativePersonaMemorySurface( + identity: RepoDiscordIdentity, + config: ReturnType, + registryIdentities: RepoDiscordIdentity[] = [], + roomContext?: { + recentMessages: SourceMessage[]; + channelSnapshots: ChannelSnapshot[]; + }, + humanPronounGuidance: RepoFaceHumanPronounGuidance[] = [], +): Promise { const personaStatePath = identity.personaStatePath; if (!personaStatePath) { return [ @@ -1982,6 +1997,32 @@ async function renderNativePersonaMemorySurface(identity: RepoDiscordIdentity): ].join("\n"); } + if (extname(personaStatePath).toLowerCase() === ".cc") { + const typedState = await loadVoidSelfStateTypedDocuments({ + canonicalPath: resolve(personaStatePath), + identity: { + agentId: identity.id, + publicName: identity.displayName, + publicDescription: identity.description, + }, + }); + const statePacket = renderRepoFaceStatePacket( + identity, + typedState, + registryIdentities, + roomContext, + humanPronounGuidance, + ); + if (!config.repoFaceHeartbeats.stateProjectorEnabled) { + return rejectLeakyMemorySurface(statePacket); + } + return projectRepoFaceMemorySurface({ + identity, + statePacket, + config, + }); + } + const raw = JSON.parse(stripLeadingBom(await readFile(resolve(personaStatePath), "utf8"))) as unknown; const state = isRecord(raw) ? raw : {}; const profile = readRecord(state, "profile") ?? readRecord(state, "selfProfile") ?? state; @@ -2444,8 +2485,8 @@ function renderRepoFaceActivationProfileFacts( const sections = Object.entries(activationProfile) .map(([section, values]) => { const entries = Object.entries(values) - .sort(([, left], [, right]) => right.weight - left.weight) - .map(([key, value]) => `${key}=${value.weight.toFixed(2)}${value.note ? ` (${cleanCharacterFacingSentence(value.note)})` : ""}`); + .sort(([, left], [, right]) => activationVectorWeight(right) - activationVectorWeight(left)) + .map(([key, value]) => `${key}=${activationVectorWeight(value).toFixed(2)}${activationVectorNote(value) ? ` (${cleanCharacterFacingSentence(activationVectorNote(value) ?? "")})` : ""}`); return entries.length > 0 ? `- ${section}: ${entries.join("; ")}` : undefined; }) .filter((entry): entry is string => typeof entry === "string"); @@ -2455,6 +2496,22 @@ function renderRepoFaceActivationProfileFacts( : undefined; } +function activationVectorWeight(value: unknown): number { + if (!isRecord(value)) { + return 0; + } + const candidates = [value.weight, value.current_activation, value.currentActivation, value.mean]; + const numeric = candidates.find((candidate) => typeof candidate === "number" && Number.isFinite(candidate)); + return typeof numeric === "number" ? numeric : 0; +} + +function activationVectorNote(value: unknown): string | undefined { + if (!isRecord(value)) { + return undefined; + } + return typeof value.note === "string" ? value.note : undefined; +} + function renderRepoFaceRuntimePressureFacts( name: string, state: VoidSelfStateTypedProjection,