MCPcopy
hub / github.com/slopus/happy / updateMetadata

Method updateMetadata

packages/happy-cli/src/api/apiSession.ts:923–942  ·  view source on GitHub ↗
(handler: (metadata: Metadata) => Metadata)

Source from the content-addressed store, hash-verified

921 }
922
923 updateMetadata(handler: (metadata: Metadata) => Metadata) {
924 this.metadataLock.inLock(async () => {
925 await backoff(async () => {
926 let updated = handler(this.metadata!); // Weird state if metadata is null - should never happen but here we are
927 const answer = await this.socket.emitWithAck('update-metadata', { sid: this.sessionId, expectedVersion: this.metadataVersion, metadata: encodeBase64(encrypt(this.encryptionKey, this.encryptionVariant, updated)) });
928 if (answer.result === 'success') {
929 this.metadata = decrypt(this.encryptionKey, this.encryptionVariant, decodeBase64(answer.metadata));
930 this.metadataVersion = answer.version;
931 } else if (answer.result === 'version-mismatch') {
932 if (answer.version > this.metadataVersion) {
933 this.metadataVersion = answer.version;
934 this.metadata = decrypt(this.encryptionKey, this.encryptionVariant, decodeBase64(answer.metadata));
935 }
936 throw new Error('Metadata version mismatch');
937 } else if (answer.result === 'error') {
938 // Hard error - ignore
939 }
940 });
941 });
942 }
943
944 /**
945 * Update session agent state

Callers 12

handleKillSessionFunction · 0.80
runOpenClawFunction · 0.80
runCodexFunction · 0.80
handleKillSessionFunction · 0.80
resumeExistingThreadFunction · 0.80
onBackendMessageFunction · 0.80
runAcpFunction · 0.80
claudeRemoteLauncherFunction · 0.80
SessionClass · 0.80
runClaudeFunction · 0.80
cleanupFunction · 0.80

Calls 7

encodeBase64Function · 0.90
encryptFunction · 0.90
decryptFunction · 0.90
decodeBase64Function · 0.90
emitWithAckMethod · 0.80
handlerFunction · 0.50
inLockMethod · 0.45

Tested by

no test coverage detected