ethagent 1.1.2 → 2.0.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.
Files changed (268) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +126 -30
  3. package/package.json +7 -2
  4. package/src/app/FirstRun.tsx +190 -146
  5. package/src/app/FirstRunTimeline.tsx +47 -0
  6. package/src/app/input/AppInputProvider.tsx +1 -1
  7. package/src/app/keybindings/KeybindingProvider.tsx +1 -1
  8. package/src/chat/ChatBottomPane.tsx +0 -1
  9. package/src/chat/ChatInput.tsx +6 -6
  10. package/src/chat/ChatScreen.tsx +35 -15
  11. package/src/chat/ContextLimitView.tsx +4 -4
  12. package/src/chat/ContinuityEditReviewView.tsx +10 -22
  13. package/src/chat/CopyPicker.tsx +0 -1
  14. package/src/chat/MessageList.tsx +62 -45
  15. package/src/chat/PermissionPrompt.tsx +13 -9
  16. package/src/chat/PlanApprovalView.tsx +3 -3
  17. package/src/chat/ResumeView.tsx +1 -4
  18. package/src/chat/RewindView.tsx +2 -2
  19. package/src/chat/chatInputState.ts +1 -1
  20. package/src/chat/chatScreenUtils.ts +22 -11
  21. package/src/chat/chatSessionState.ts +2 -2
  22. package/src/chat/chatTurnOrchestrator.ts +16 -81
  23. package/src/chat/commands.ts +1 -1
  24. package/src/chat/textCursor.ts +1 -1
  25. package/src/chat/transcriptViewport.ts +2 -7
  26. package/src/cli/ResetConfirmView.tsx +1 -1
  27. package/src/cli/main.tsx +9 -3
  28. package/src/cli/preview.tsx +0 -5
  29. package/src/cli/updateNotice.ts +4 -2
  30. package/src/identity/continuity/editor.ts +7 -107
  31. package/src/identity/continuity/envelope.ts +1048 -40
  32. package/src/identity/continuity/history.ts +4 -4
  33. package/src/identity/continuity/localBackup.ts +249 -0
  34. package/src/identity/continuity/privateEdit/apply.ts +170 -0
  35. package/src/identity/continuity/privateEdit/diff.ts +82 -0
  36. package/src/identity/continuity/privateEdit/files.ts +23 -0
  37. package/src/identity/continuity/privateEdit/types.ts +28 -0
  38. package/src/identity/continuity/privateEdit.ts +10 -298
  39. package/src/identity/continuity/publicSkills.ts +8 -9
  40. package/src/identity/continuity/snapshots.ts +17 -6
  41. package/src/identity/continuity/storage/defaults.ts +111 -0
  42. package/src/identity/continuity/storage/files.ts +72 -0
  43. package/src/identity/continuity/storage/markdown.ts +81 -0
  44. package/src/identity/continuity/storage/paths.ts +24 -0
  45. package/src/identity/continuity/storage/scaffold.ts +124 -0
  46. package/src/identity/continuity/storage/status.ts +86 -0
  47. package/src/identity/continuity/storage/types.ts +27 -0
  48. package/src/identity/continuity/storage.ts +32 -507
  49. package/src/identity/continuity/zipWriter.ts +95 -0
  50. package/src/identity/crypto/backupEnvelope.ts +14 -247
  51. package/src/identity/crypto/eth.ts +7 -7
  52. package/src/identity/ens/agentRecords.ts +96 -0
  53. package/src/identity/ens/ensAutomation/contracts.ts +38 -0
  54. package/src/identity/ens/ensAutomation/delete.ts +80 -0
  55. package/src/identity/ens/ensAutomation/names.ts +14 -0
  56. package/src/identity/ens/ensAutomation/operators.ts +29 -0
  57. package/src/identity/ens/ensAutomation/read.ts +114 -0
  58. package/src/identity/ens/ensAutomation/root.ts +63 -0
  59. package/src/identity/ens/ensAutomation/setup.ts +284 -0
  60. package/src/identity/ens/ensAutomation/transactions.ts +107 -0
  61. package/src/identity/ens/ensAutomation/types.ts +126 -0
  62. package/src/identity/ens/ensAutomation.ts +29 -0
  63. package/src/identity/ens/ensLookup/client.ts +43 -0
  64. package/src/identity/ens/ensLookup/constants.ts +26 -0
  65. package/src/identity/ens/ensLookup/discovery.ts +70 -0
  66. package/src/identity/ens/ensLookup/names.ts +34 -0
  67. package/src/identity/ens/ensLookup/records.ts +45 -0
  68. package/src/identity/ens/ensLookup/resolve.ts +75 -0
  69. package/src/identity/ens/ensLookup/tokenReference.ts +17 -0
  70. package/src/identity/ens/ensLookup/types.ts +38 -0
  71. package/src/identity/ens/ensLookup/validation.ts +72 -0
  72. package/src/identity/ens/ensLookup.ts +19 -0
  73. package/src/identity/ens/ensRegistration.ts +199 -0
  74. package/src/identity/ens/resolverDelegation.ts +48 -0
  75. package/src/identity/hub/IdentityHub.tsx +13 -817
  76. package/src/identity/hub/OperationalRoutes.tsx +370 -0
  77. package/src/identity/hub/Routes.tsx +361 -0
  78. package/src/identity/hub/advancedEnsValidation.ts +45 -0
  79. package/src/identity/hub/{screens → components}/DetailsScreen.tsx +14 -8
  80. package/src/identity/hub/{screens → components}/ErrorScreen.tsx +15 -5
  81. package/src/identity/hub/components/FlowTimeline.tsx +27 -0
  82. package/src/identity/hub/components/IdentitySummary.tsx +190 -0
  83. package/src/identity/hub/components/MenuScreen.tsx +237 -0
  84. package/src/identity/hub/{screens → components}/NetworkScreen.tsx +3 -3
  85. package/src/identity/hub/{screens/RebackupStorageScreen.tsx → components/PinataJwtInput.tsx} +21 -18
  86. package/src/identity/hub/components/UnlinkedIdentityScreen.tsx +76 -0
  87. package/src/identity/hub/{screens → components}/WalletApprovalScreen.tsx +9 -8
  88. package/src/identity/hub/components/menuFlagsFromReconciliation.ts +68 -0
  89. package/src/identity/hub/effects/create.ts +310 -0
  90. package/src/identity/hub/effects/ens/flows.ts +218 -0
  91. package/src/identity/hub/effects/ens/index.ts +11 -0
  92. package/src/identity/hub/effects/ens/transactions.ts +239 -0
  93. package/src/identity/hub/effects/index.ts +74 -0
  94. package/src/identity/hub/effects/profile/profileState.ts +173 -0
  95. package/src/identity/hub/effects/publicProfile/index.ts +5 -0
  96. package/src/identity/hub/effects/publicProfile/runPublicProfileSave.ts +646 -0
  97. package/src/identity/hub/effects/rebackup/index.ts +7 -0
  98. package/src/identity/hub/effects/rebackup/operatorVault.ts +378 -0
  99. package/src/identity/hub/effects/rebackup/runRebackup.ts +451 -0
  100. package/src/identity/hub/effects/receipts.ts +46 -0
  101. package/src/identity/hub/effects/restore/apply.ts +112 -0
  102. package/src/identity/hub/effects/restore/auth.ts +159 -0
  103. package/src/identity/hub/effects/restore/discover.ts +86 -0
  104. package/src/identity/hub/effects/restore/envelopes.ts +21 -0
  105. package/src/identity/hub/effects/restore/fetch.ts +25 -0
  106. package/src/identity/hub/effects/restore/index.ts +22 -0
  107. package/src/identity/hub/effects/restore/recovery.ts +135 -0
  108. package/src/identity/hub/effects/restore/resolve.ts +102 -0
  109. package/src/identity/hub/effects/restore/restoreEffects.ts +22 -0
  110. package/src/identity/hub/effects/restore/shared.ts +91 -0
  111. package/src/identity/hub/effects/restoreAdmin.ts +93 -0
  112. package/src/identity/hub/effects/shared/profilePrep.ts +139 -0
  113. package/src/identity/hub/effects/shared/snapshot.ts +336 -0
  114. package/src/identity/hub/effects/shared/sync.ts +190 -0
  115. package/src/identity/hub/effects/token-transfer/index.ts +6 -0
  116. package/src/identity/hub/effects/token-transfer/progress.ts +59 -0
  117. package/src/identity/hub/effects/token-transfer/runTokenTransfer.ts +299 -0
  118. package/src/identity/hub/effects/types.ts +53 -0
  119. package/src/identity/hub/effects/vault/preflight.ts +50 -0
  120. package/src/identity/hub/flows/continuity/ContinuityDashboardScreen.tsx +170 -0
  121. package/src/identity/hub/flows/continuity/RebackupStorageScreen.tsx +28 -0
  122. package/src/identity/hub/{screens → flows/continuity}/RecoveryConfirmScreen.tsx +28 -19
  123. package/src/identity/hub/flows/continuity/SavePromptScreen.tsx +49 -0
  124. package/src/identity/hub/{screens → flows/create}/CreateFlow.tsx +61 -62
  125. package/src/identity/hub/flows/custody/CustodyEditFlow.tsx +347 -0
  126. package/src/identity/hub/flows/custody/custodyEffects.ts +321 -0
  127. package/src/identity/hub/flows/custody/custodyFlowActions.ts +236 -0
  128. package/src/identity/hub/flows/custody/custodyFlowEffects.ts +163 -0
  129. package/src/identity/hub/flows/custody/custodyFlowHelpers.ts +25 -0
  130. package/src/identity/hub/flows/custody/custodyFlowRoutes.tsx +239 -0
  131. package/src/identity/hub/flows/custody/custodyFlowTypes.ts +45 -0
  132. package/src/identity/hub/flows/custody/useCustodyFlow.tsx +25 -0
  133. package/src/identity/hub/flows/ens/EnsEditAdvancedScreens.tsx +336 -0
  134. package/src/identity/hub/flows/ens/EnsEditFlow.tsx +397 -0
  135. package/src/identity/hub/flows/ens/EnsEditMaintenanceScreens.tsx +332 -0
  136. package/src/identity/hub/flows/ens/EnsEditReviewScreens.tsx +471 -0
  137. package/src/identity/hub/flows/ens/EnsEditRunners.tsx +198 -0
  138. package/src/identity/hub/flows/ens/EnsEditShared.tsx +162 -0
  139. package/src/identity/hub/flows/ens/EnsEditSimpleScreens.tsx +518 -0
  140. package/src/identity/hub/flows/ens/IdentityHubEnsFlow.tsx +299 -0
  141. package/src/identity/hub/flows/ens/OperatorWalletsScreen.tsx +398 -0
  142. package/src/identity/hub/flows/ens/ensEditCopy.ts +117 -0
  143. package/src/identity/hub/flows/ens/ensEditTypes.ts +91 -0
  144. package/src/identity/hub/flows/profile/EditProfileFlow.tsx +271 -0
  145. package/src/identity/hub/flows/restore/RestoreFlow.tsx +324 -0
  146. package/src/identity/hub/flows/restore/useRestoreFlowEffects.ts +77 -0
  147. package/src/identity/hub/{screens → flows/settings}/StorageCredentialScreen.tsx +23 -44
  148. package/src/identity/hub/flows/token-transfer/IdentityHubTokenTransferFlow.tsx +162 -0
  149. package/src/identity/hub/flows/token-transfer/TokenTransferScreens.tsx +256 -0
  150. package/src/identity/hub/identityHubReducer.ts +164 -99
  151. package/src/identity/hub/model/continuity.ts +94 -0
  152. package/src/identity/hub/model/copy.ts +35 -0
  153. package/src/identity/hub/model/custody.ts +54 -0
  154. package/src/identity/hub/model/ens.ts +49 -0
  155. package/src/identity/hub/model/errors.ts +140 -0
  156. package/src/identity/hub/model/format.ts +15 -0
  157. package/src/identity/hub/model/identity.ts +94 -0
  158. package/src/identity/hub/model/network.ts +32 -0
  159. package/src/identity/hub/model/transfer.ts +57 -0
  160. package/src/identity/hub/operatorWallets.ts +131 -0
  161. package/src/identity/hub/reconciliation/agentReconciliation/hook.ts +46 -0
  162. package/src/identity/hub/reconciliation/agentReconciliation/ownership.ts +129 -0
  163. package/src/identity/hub/reconciliation/agentReconciliation/run.ts +302 -0
  164. package/src/identity/hub/reconciliation/agentReconciliation/types.ts +17 -0
  165. package/src/identity/hub/reconciliation/index.ts +21 -0
  166. package/src/identity/hub/reconciliation/useAgentReconciliation.ts +10 -0
  167. package/src/identity/hub/reconciliation/walletSetup.ts +220 -0
  168. package/src/identity/hub/txGuard.ts +51 -0
  169. package/src/identity/hub/types.ts +17 -0
  170. package/src/identity/hub/useIdentityHubContinuity.ts +136 -0
  171. package/src/identity/hub/useIdentityHubController.ts +396 -0
  172. package/src/identity/hub/useIdentityHubSideEffects.ts +309 -0
  173. package/src/identity/hub/utils.ts +79 -0
  174. package/src/identity/identityCompat.ts +34 -0
  175. package/src/identity/profile/agentIcon.ts +61 -0
  176. package/src/identity/profile/imagePicker.ts +12 -12
  177. package/src/identity/registry/erc8004/abi.ts +14 -0
  178. package/src/identity/registry/erc8004/chains.ts +150 -0
  179. package/src/identity/registry/erc8004/client.ts +11 -0
  180. package/src/identity/registry/erc8004/discovery.ts +511 -0
  181. package/src/identity/registry/erc8004/metadata.ts +335 -0
  182. package/src/identity/registry/erc8004/ownership.ts +121 -0
  183. package/src/identity/registry/erc8004/preflight.ts +123 -0
  184. package/src/identity/registry/erc8004/transactions.ts +77 -0
  185. package/src/identity/registry/erc8004/types.ts +88 -0
  186. package/src/identity/registry/erc8004/uri.ts +59 -0
  187. package/src/identity/registry/erc8004/utils.ts +58 -0
  188. package/src/identity/registry/erc8004.ts +53 -1106
  189. package/src/identity/registry/fieldParsers.ts +28 -0
  190. package/src/identity/registry/operatorVault/bytecode.ts +98 -0
  191. package/src/identity/registry/operatorVault/constants.ts +38 -0
  192. package/src/identity/registry/operatorVault/read.ts +246 -0
  193. package/src/identity/registry/operatorVault/transactions.ts +81 -0
  194. package/src/identity/registry/operatorVault.ts +44 -0
  195. package/src/identity/storage/ipfs.ts +26 -24
  196. package/src/identity/wallet/browserWallet/gas.ts +41 -0
  197. package/src/identity/wallet/browserWallet/html.ts +106 -0
  198. package/src/identity/wallet/browserWallet/http.ts +28 -0
  199. package/src/identity/wallet/browserWallet/requestServer.ts +106 -0
  200. package/src/identity/wallet/browserWallet/requests.ts +191 -0
  201. package/src/identity/wallet/browserWallet/session.ts +325 -0
  202. package/src/identity/wallet/browserWallet/types.ts +192 -0
  203. package/src/identity/wallet/browserWallet/validation.ts +74 -0
  204. package/src/identity/wallet/browserWallet.ts +30 -393
  205. package/src/identity/wallet/page/constants.ts +5 -0
  206. package/src/identity/wallet/page/controller.ts +251 -0
  207. package/src/identity/wallet/page/copy.ts +340 -0
  208. package/src/identity/wallet/page/grainient.ts +278 -0
  209. package/src/identity/wallet/page/html.ts +28 -0
  210. package/src/identity/wallet/page/markup.ts +50 -0
  211. package/src/identity/wallet/page/state.ts +9 -0
  212. package/src/identity/wallet/page/styles/base.ts +259 -0
  213. package/src/identity/wallet/page/styles/components.ts +262 -0
  214. package/src/identity/wallet/page/styles/index.ts +5 -0
  215. package/src/identity/wallet/page/styles/responsive.ts +247 -0
  216. package/src/identity/wallet/page/types.ts +47 -0
  217. package/src/identity/wallet/page/view.ts +535 -0
  218. package/src/identity/wallet/page/walletProvider.ts +70 -0
  219. package/src/identity/wallet/page.tsx +38 -0
  220. package/src/identity/wallet/walletPurposeCompat.ts +27 -0
  221. package/src/mcp/manager.ts +0 -1
  222. package/src/models/ModelPicker.tsx +36 -30
  223. package/src/models/catalog.ts +5 -2
  224. package/src/models/huggingface.ts +9 -9
  225. package/src/models/llamacpp.ts +13 -13
  226. package/src/models/modelDisplay.ts +75 -0
  227. package/src/models/modelPickerOptions.ts +16 -3
  228. package/src/models/modelRecommendation.ts +0 -1
  229. package/src/providers/errors.ts +16 -0
  230. package/src/providers/gemini.ts +252 -39
  231. package/src/providers/registry.ts +2 -2
  232. package/src/providers/retry.ts +1 -1
  233. package/src/runtime/sessionMode.ts +1 -1
  234. package/src/runtime/systemPrompt.ts +2 -0
  235. package/src/runtime/toolExecution.ts +18 -22
  236. package/src/runtime/toolIntent.ts +0 -20
  237. package/src/runtime/turn.ts +0 -92
  238. package/src/storage/atomicWrite.ts +4 -1
  239. package/src/storage/config.ts +181 -5
  240. package/src/storage/identity.ts +9 -3
  241. package/src/storage/secrets.ts +2 -2
  242. package/src/tools/bashSafety.ts +8 -0
  243. package/src/tools/changeDirectoryTool.ts +1 -1
  244. package/src/tools/deleteFileTool.ts +4 -4
  245. package/src/tools/editTool.ts +4 -4
  246. package/src/tools/editUtils.ts +5 -5
  247. package/src/tools/privateContinuityEditTool.ts +4 -5
  248. package/src/tools/privateContinuityReadTool.ts +1 -2
  249. package/src/tools/registry.ts +30 -0
  250. package/src/tools/writeFileTool.ts +5 -5
  251. package/src/ui/BrandSplash.tsx +20 -85
  252. package/src/ui/ProgressBar.tsx +3 -5
  253. package/src/ui/Select.tsx +20 -8
  254. package/src/ui/Spinner.tsx +38 -3
  255. package/src/ui/Surface.tsx +2 -2
  256. package/src/ui/TextInput.tsx +63 -20
  257. package/src/ui/theme.ts +7 -34
  258. package/src/utils/openExternal.ts +21 -0
  259. package/src/utils/withRetry.ts +47 -3
  260. package/src/identity/hub/identityHubEffects.ts +0 -937
  261. package/src/identity/hub/identityHubModel.ts +0 -371
  262. package/src/identity/hub/screens/ContinuityDashboardScreen.tsx +0 -156
  263. package/src/identity/hub/screens/EditProfileFlow.tsx +0 -146
  264. package/src/identity/hub/screens/IdentitySummary.tsx +0 -106
  265. package/src/identity/hub/screens/MenuScreen.tsx +0 -117
  266. package/src/identity/hub/screens/RestoreFlow.tsx +0 -206
  267. package/src/identity/wallet/wallet-page/wallet.html +0 -1202
  268. /package/src/identity/hub/{screens → components}/BusyScreen.tsx +0 -0
@@ -0,0 +1,370 @@
1
+ import React from 'react'
2
+ import { hasPendingPublish } from './model/continuity.js'
3
+ import type { ProfileUpdates } from './identityHubReducer.js'
4
+ import { clearPinataJwt, savePinataJwt } from '../storage/pinataJwt.js'
5
+ import {
6
+ runFixRecordsSubmit,
7
+ } from './effects/restoreAdmin.js'
8
+ import {
9
+ runRebackupStorageSubmit,
10
+ } from './effects/rebackup/runRebackup.js'
11
+ import {
12
+ runPublicProfileStorageSubmit,
13
+ } from './effects/publicProfile/runPublicProfileSave.js'
14
+ import { resolveOperatorVaultAddress } from './flows/custody/custodyEffects.js'
15
+ import { WalletApprovalScreen } from './components/WalletApprovalScreen.js'
16
+ import { RebackupStorageScreen } from './flows/continuity/RebackupStorageScreen.js'
17
+ import { BusyScreen } from './components/BusyScreen.js'
18
+ import { StorageCredentialScreen } from './flows/settings/StorageCredentialScreen.js'
19
+ import {
20
+ PrivateContinuityScreen,
21
+ PublicProfileScreen,
22
+ } from './flows/continuity/ContinuityDashboardScreen.js'
23
+ import { RecoveryConfirmScreen } from './flows/continuity/RecoveryConfirmScreen.js'
24
+ import { SavePromptScreen } from './flows/continuity/SavePromptScreen.js'
25
+ import { ErrorScreen } from './components/ErrorScreen.js'
26
+ import { UnlinkedIdentityScreen } from './components/UnlinkedIdentityScreen.js'
27
+ import { invalidateOwnershipCache } from './reconciliation/index.js'
28
+ import {
29
+ IdentityHubEnsFlow,
30
+ isIdentityHubEnsStep,
31
+ } from './flows/ens/IdentityHubEnsFlow.js'
32
+ import { CustodyEditFlow, isCustodyEditStep } from './flows/custody/CustodyEditFlow.js'
33
+ import { rebackupWalletApprovalView } from './utils.js'
34
+ import type { IdentityHubController } from './useIdentityHubController.js'
35
+
36
+ type IdentityHubOperationalRoutesProps = {
37
+ controller: IdentityHubController
38
+ footer: React.ReactNode
39
+ }
40
+
41
+ export const IdentityHubOperationalRoutes: React.FC<IdentityHubOperationalRoutesProps> = ({
42
+ controller,
43
+ footer,
44
+ }) => {
45
+ const {
46
+ mode,
47
+ config,
48
+ onComplete,
49
+ identity,
50
+ reconciliation,
51
+ step,
52
+ walletSession,
53
+ restoreProgress,
54
+ jwtSaved,
55
+ callbacks,
56
+ custodyFlow,
57
+ continuityReady,
58
+ workingStatus,
59
+ setStep,
60
+ back,
61
+ closeHub,
62
+ setWalletSession,
63
+ setJwtSaved,
64
+ setCopyNotice,
65
+ handleStepError,
66
+ resolveRegistryForIdentity,
67
+ triggerRebackup,
68
+ triggerPublicProfileSave,
69
+ openTokenTransferFlow,
70
+ openPublicProfileEdit,
71
+ openContinuityFile,
72
+ exportLocalBackupZip,
73
+ } = controller
74
+
75
+ if (step.kind === 'rebackup-confirm') {
76
+ return (
77
+ <RecoveryConfirmScreen
78
+ mode="publish"
79
+ workingStatus={workingStatus}
80
+ footer={footer}
81
+ onConfirm={() => triggerRebackup(step.back)}
82
+ onBack={back}
83
+ />
84
+ )
85
+ }
86
+
87
+ if (step.kind === 'save-prompt') {
88
+ return (
89
+ <SavePromptScreen
90
+ workingStatus={workingStatus}
91
+ footer={footer}
92
+ onSelect={action => {
93
+ if (action === 'save-now') {
94
+ triggerRebackup(step.back)
95
+ return
96
+ }
97
+ onComplete({ kind: 'cancel' })
98
+ }}
99
+ onCancel={() => onComplete({ kind: 'cancel' })}
100
+ />
101
+ )
102
+ }
103
+
104
+ if (step.kind === 'recovery-refetch-confirm') {
105
+ return (
106
+ <RecoveryConfirmScreen
107
+ mode="refetch"
108
+ workingStatus={workingStatus}
109
+ pendingPublish={hasPendingPublish(identity)}
110
+ footer={footer}
111
+ onConfirm={() => {
112
+ if (!identity) return
113
+ const registry = resolveRegistryForIdentity(identity)
114
+ if (!registry) {
115
+ handleStepError(new Error('no agent registry configured for this identity'), step.back)
116
+ return
117
+ }
118
+ setStep({ kind: 'recovery-refetching', identity, registry, back: step.back })
119
+ }}
120
+ onBack={back}
121
+ />
122
+ )
123
+ }
124
+
125
+ if (step.kind === 'recovery-refetching') {
126
+ return (
127
+ <WalletApprovalScreen
128
+ title="Refetch Latest Snapshot"
129
+ subtitle="Wallet signature decrypts the latest saved snapshot and restores SOUL.md, MEMORY.md, and skills.json."
130
+ walletSession={walletSession}
131
+ label={restoreProgress?.label ?? 'fetching latest snapshot from chain...'}
132
+ onCancel={() => setStep(step.back)}
133
+ />
134
+ )
135
+ }
136
+
137
+ if (step.kind === 'continuity-private') {
138
+ return (
139
+ <PrivateContinuityScreen
140
+ identity={identity}
141
+ config={config}
142
+ workingStatus={workingStatus}
143
+ ready={continuityReady}
144
+ notice={step.notice}
145
+ footer={footer}
146
+ editorOpened={step.editorOpened}
147
+ onOpenSoul={() => { void openContinuityFile('soul') }}
148
+ onOpenMemory={() => { void openContinuityFile('memory') }}
149
+ onOpenSkills={() => { void openContinuityFile('skills') }}
150
+ onExportBackup={() => { void exportLocalBackupZip() }}
151
+ onBack={back}
152
+ />
153
+ )
154
+ }
155
+
156
+ if (step.kind === 'continuity-public') {
157
+ return (
158
+ <PublicProfileScreen
159
+ identity={identity}
160
+ config={config}
161
+ workingStatus={workingStatus}
162
+ ready={continuityReady}
163
+ notice={step.notice}
164
+ footer={footer}
165
+ editorOpened={step.editorOpened}
166
+ onEditProfile={() => openPublicProfileEdit({ kind: 'continuity-public' })}
167
+ onBack={back}
168
+ />
169
+ )
170
+ }
171
+
172
+ if (step.kind === 'storage-credential' || step.kind === 'storage-credential-input' || step.kind === 'storage-credential-forget-confirm') {
173
+ return (
174
+ <StorageCredentialScreen
175
+ step={step}
176
+ hasCredential={jwtSaved}
177
+ footer={footer}
178
+ onEdit={() => setStep({ kind: 'storage-credential-input' })}
179
+ onForget={() => setStep({ kind: 'storage-credential-forget-confirm' })}
180
+ onConfirmForget={async () => {
181
+ await clearPinataJwt().catch(() => {})
182
+ setJwtSaved(false)
183
+ setCopyNotice('IPFS storage credential removed.')
184
+ setStep({ kind: 'menu' })
185
+ }}
186
+ onSubmit={async input => {
187
+ try {
188
+ await savePinataJwt(input)
189
+ setJwtSaved(true)
190
+ setCopyNotice('IPFS storage credential saved.')
191
+ setStep({ kind: 'menu' })
192
+ } catch (err: unknown) {
193
+ setStep({ kind: 'storage-credential-input', error: (err as Error).message })
194
+ }
195
+ }}
196
+ onCancel={back}
197
+ />
198
+ )
199
+ }
200
+
201
+ if (isIdentityHubEnsStep(step)) {
202
+ return (
203
+ <IdentityHubEnsFlow
204
+ step={step}
205
+ walletSession={walletSession}
206
+ onSetStep={setStep}
207
+ onBack={back}
208
+ onWalletReady={setWalletSession}
209
+ onTriggerRebackup={triggerRebackup}
210
+ onTriggerPublicProfileSave={triggerPublicProfileSave}
211
+ />
212
+ )
213
+ }
214
+
215
+ {
216
+ const custodyView = custodyFlow.renderCustodyStep()
217
+ if (custodyView) return custodyView
218
+ }
219
+
220
+ if (isCustodyEditStep(step)) {
221
+ return (
222
+ <CustodyEditFlow
223
+ step={step}
224
+ reconciliation={reconciliation}
225
+ vaultAddress={resolveOperatorVaultAddress(step.identity, config?.erc8004?.operatorVaults)}
226
+ onSetStep={setStep}
227
+ onSwitchToAdvanced={(returnTo, updates) => custodyFlow.beginVaultDeposit(step, returnTo, updates)}
228
+ onSwitchToSimple={(returnTo, updates) => custodyFlow.beginVaultUnwrap(step, returnTo, updates)}
229
+ onWithdrawToken={returnTo => custodyFlow.beginWithdrawToken(step, returnTo)}
230
+ onReturnToVault={(returnTo, vaultAddress) => custodyFlow.beginReturnToVault(step, returnTo, vaultAddress)}
231
+ onResumeAdvanced={returnTo => {
232
+ const vaultAddress = resolveOperatorVaultAddress(step.identity, config?.erc8004?.operatorVaults)
233
+ const updates: ProfileUpdates = {
234
+ custodyMode: 'advanced',
235
+ ownerAddress: step.identity.ownerAddress ?? step.identity.address,
236
+ ...(vaultAddress ? { operatorVaultAddress: vaultAddress } : {}),
237
+ }
238
+ triggerRebackup(returnTo, updates, vaultAddress ? { vaultAddress } : undefined)
239
+ }}
240
+ onManageOperatorWallets={() => {
241
+ setStep({ kind: 'manage-ens-operators', identity: step.identity, registry: step.registry, returnTo: step })
242
+ }}
243
+ onFixRecords={async plan => {
244
+ try {
245
+ await runFixRecordsSubmit({ identity: step.identity, registry: step.registry, plan, callbacks })
246
+ setStep({ ...step })
247
+ } catch (err: unknown) {
248
+ handleStepError(err, step)
249
+ }
250
+ }}
251
+ onPrepareTransfer={openTokenTransferFlow}
252
+ onBack={back}
253
+ />
254
+ )
255
+ }
256
+
257
+ if (step.kind === 'rebackup-signing') {
258
+ const approval = rebackupWalletApprovalView(step.identity, step.profileUpdates)
259
+ return (
260
+ <WalletApprovalScreen
261
+ title={approval.title}
262
+ subtitle={custodyFlow.renderRebackupSubtitle(
263
+ approval.subtitle,
264
+ Boolean(step.vaultAddress),
265
+ )}
266
+ walletSession={walletSession}
267
+ label={approval.label}
268
+ onCancel={() => setStep(step.returnTo ?? { kind: 'menu' })}
269
+ />
270
+ )
271
+ }
272
+
273
+ if (step.kind === 'rebackup-start') {
274
+ return (
275
+ <BusyScreen
276
+ title="Identity Hub"
277
+ label="preparing encrypted snapshot..."
278
+ onCancel={back}
279
+ />
280
+ )
281
+ }
282
+
283
+ if (step.kind === 'rebackup-storage') {
284
+ return (
285
+ <RebackupStorageScreen
286
+ step={step}
287
+ footer={footer}
288
+ onSubmit={async input => {
289
+ try {
290
+ await runRebackupStorageSubmit(input, step, callbacks)
291
+ } catch (err: unknown) {
292
+ setStep({ ...step, error: (err as Error).message })
293
+ }
294
+ }}
295
+ onCancel={back}
296
+ />
297
+ )
298
+ }
299
+
300
+ if (step.kind === 'public-profile-storage') {
301
+ return (
302
+ <RebackupStorageScreen
303
+ step={step}
304
+ footer={footer}
305
+ onSubmit={async input => {
306
+ try {
307
+ await runPublicProfileStorageSubmit(input, step, callbacks)
308
+ } catch (err: unknown) {
309
+ setStep({ ...step, error: (err as Error).message })
310
+ }
311
+ }}
312
+ onCancel={back}
313
+ />
314
+ )
315
+ }
316
+
317
+ if (step.kind === 'restore-wallet') {
318
+ return (
319
+ <WalletApprovalScreen
320
+ title="Connect Wallet"
321
+ subtitle="Find agents this wallet owns, whether held directly or linked to it."
322
+ walletSession={walletSession}
323
+ label="waiting for wallet connection..."
324
+ onCancel={() => setStep({ kind: 'menu' })}
325
+ />
326
+ )
327
+ }
328
+
329
+ if (step.kind === 'busy') {
330
+ return (
331
+ <BusyScreen
332
+ title="Identity Hub"
333
+ label={step.label}
334
+ onCancel={back}
335
+ />
336
+ )
337
+ }
338
+
339
+ if (step.kind === 'error') {
340
+ return (
341
+ <ErrorScreen
342
+ error={step.error}
343
+ back={step.back}
344
+ footer={footer}
345
+ closeLabel={mode === 'first-run' ? 'Skip Identity For Now' : 'Close Identity Hub'}
346
+ closeHint={mode === 'first-run' ? 'Continue First-Run Setup without an agent identity' : 'Return to chat without retrying'}
347
+ onBack={backStep => setStep(backStep)}
348
+ onClose={closeHub}
349
+ />
350
+ )
351
+ }
352
+
353
+ if (step.kind === 'identity-unlinked') {
354
+ return (
355
+ <UnlinkedIdentityScreen
356
+ identity={step.identity}
357
+ {...(step.identity.agentId ? { agentId: step.identity.agentId } : {})}
358
+ onLoadAgent={() => setStep({ kind: 'restore-network', ownerHandle: '', purpose: 'switch' })}
359
+ onOpenMenu={() => setStep({ kind: 'menu' })}
360
+ onRetry={() => {
361
+ invalidateOwnershipCache()
362
+ setStep(step.back)
363
+ }}
364
+ onCancel={() => setStep(step.back)}
365
+ />
366
+ )
367
+ }
368
+
369
+ return null
370
+ }