ethagent 2.1.1 → 2.3.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 (177) hide show
  1. package/package.json +2 -1
  2. package/src/app/FirstRun.tsx +1 -7
  3. package/src/app/FirstRunTimeline.tsx +1 -1
  4. package/src/auth/openaiOAuth/credentials.ts +47 -0
  5. package/src/auth/openaiOAuth/crypto.ts +23 -0
  6. package/src/auth/openaiOAuth/index.ts +238 -0
  7. package/src/auth/openaiOAuth/landingPage.ts +125 -0
  8. package/src/auth/openaiOAuth/listener.ts +151 -0
  9. package/src/auth/openaiOAuth/refresh.ts +70 -0
  10. package/src/auth/openaiOAuth/shared.ts +115 -0
  11. package/src/chat/ChatBottomPane.tsx +20 -11
  12. package/src/chat/ChatScreen.tsx +160 -35
  13. package/src/chat/ConversationStack.tsx +1 -1
  14. package/src/chat/MessageList.tsx +185 -72
  15. package/src/chat/SessionStatus.tsx +3 -1
  16. package/src/chat/chatScreenUtils.ts +11 -15
  17. package/src/chat/chatSessionState.ts +3 -2
  18. package/src/chat/chatTurnOrchestrator.ts +1 -7
  19. package/src/chat/commands.ts +28 -27
  20. package/src/chat/display/DiffView.tsx +193 -0
  21. package/src/chat/display/SyntaxText.tsx +192 -0
  22. package/src/chat/display/toolCallDisplay.ts +103 -0
  23. package/src/chat/display/toolResultDisplay.ts +19 -0
  24. package/src/chat/{ChatInput.tsx → input/ChatInput.tsx} +36 -23
  25. package/src/chat/{TranscriptView.tsx → transcript/TranscriptView.tsx} +24 -50
  26. package/src/chat/{transcriptViewport.ts → transcript/transcriptViewport.ts} +12 -30
  27. package/src/chat/{ContextLimitView.tsx → views/ContextLimitView.tsx} +3 -3
  28. package/src/chat/{ContinuityEditReviewView.tsx → views/ContinuityEditReviewView.tsx} +11 -3
  29. package/src/chat/{CopyPicker.tsx → views/CopyPicker.tsx} +4 -5
  30. package/src/chat/{PermissionPrompt.tsx → views/PermissionPrompt.tsx} +16 -17
  31. package/src/chat/{PermissionsView.tsx → views/PermissionsView.tsx} +6 -6
  32. package/src/chat/{PlanApprovalView.tsx → views/PlanApprovalView.tsx} +4 -4
  33. package/src/chat/{ResumeView.tsx → views/ResumeView.tsx} +35 -35
  34. package/src/chat/views/RewindView.tsx +410 -0
  35. package/src/identity/continuity/privateEdit/diff.ts +2 -78
  36. package/src/identity/ens/agentRecords.ts +5 -19
  37. package/src/identity/ens/ensAutomation/setup.ts +0 -1
  38. package/src/identity/ens/ensAutomation/types.ts +0 -1
  39. package/src/identity/hub/OperationalRoutes.tsx +23 -32
  40. package/src/identity/hub/Routes.tsx +13 -13
  41. package/src/identity/hub/{flows/continuity → continuity}/ContinuityDashboardScreen.tsx +9 -9
  42. package/src/identity/hub/{flows/continuity → continuity}/RebackupStorageScreen.tsx +2 -2
  43. package/src/identity/hub/{flows/continuity → continuity}/RecoveryConfirmScreen.tsx +5 -5
  44. package/src/identity/hub/{flows/continuity → continuity}/SavePromptScreen.tsx +5 -5
  45. package/src/identity/hub/{effects/rebackup/runRebackup.ts → continuity/effects.ts} +19 -19
  46. package/src/identity/hub/{effects/rebackup → continuity}/index.ts +1 -1
  47. package/src/identity/hub/{effects/shared → continuity}/snapshot.ts +8 -8
  48. package/src/identity/hub/{effects/rebackup → continuity}/vault.ts +15 -15
  49. package/src/identity/hub/{flows/create → create}/CreateFlow.tsx +13 -13
  50. package/src/identity/hub/{effects/create.ts → create/effects.ts} +4 -4
  51. package/src/identity/hub/{flows/custody → custody}/CustodyEditFlow.tsx +10 -48
  52. package/src/identity/hub/{flows/custody/custodyFlowActions.ts → custody/actions.ts} +11 -9
  53. package/src/identity/hub/{flows/custody/custodyFlowHelpers.ts → custody/helpers.ts} +4 -4
  54. package/src/identity/hub/{effects/vault → custody}/preflight.ts +5 -5
  55. package/src/identity/hub/{flows/custody/custodyFlowRoutes.tsx → custody/routes.tsx} +8 -8
  56. package/src/identity/hub/{flows/custody/custodyEffects.ts → custody/transactions.ts} +9 -9
  57. package/src/identity/hub/{flows/custody/custodyFlowTypes.ts → custody/types.ts} +6 -6
  58. package/src/identity/hub/{flows/custody/custodyFlowEffects.ts → custody/useCustodyEffects.ts} +7 -7
  59. package/src/identity/hub/{flows/custody → custody}/useCustodyFlow.tsx +5 -5
  60. package/src/identity/hub/ens/EnsEditAdvancedScreens.tsx +241 -0
  61. package/src/identity/hub/{flows/ens → ens}/EnsEditFlow.tsx +27 -82
  62. package/src/identity/hub/{flows/ens → ens}/EnsEditMaintenanceScreens.tsx +25 -65
  63. package/src/identity/hub/{flows/ens → ens}/EnsEditReviewScreens.tsx +12 -30
  64. package/src/identity/hub/ens/EnsEditRunners.tsx +62 -0
  65. package/src/identity/hub/{flows/ens → ens}/EnsEditShared.tsx +15 -14
  66. package/src/identity/hub/{flows/ens → ens}/EnsEditSimpleScreens.tsx +68 -217
  67. package/src/identity/hub/{flows/ens/IdentityHubEnsFlow.tsx → ens/EnsFlow.tsx} +18 -11
  68. package/src/identity/hub/{flows/ens/OperatorWalletsScreen.tsx → ens/EnsOperatorWalletsScreen.tsx} +17 -48
  69. package/src/identity/hub/{advancedEnsValidation.ts → ens/advancedEnsValidation.ts} +2 -2
  70. package/src/identity/hub/{flows/ens/ensEditCopy.ts → ens/editCopy.ts} +4 -4
  71. package/src/identity/hub/{effects/ens/flows.ts → ens/effects.ts} +7 -7
  72. package/src/identity/hub/{effects/ens → ens}/index.ts +1 -1
  73. package/src/identity/hub/{model/ens.ts → ens/state.ts} +1 -1
  74. package/src/identity/hub/{effects/ens → ens}/transactions.ts +232 -232
  75. package/src/identity/hub/{flows/ens/ensEditTypes.ts → ens/types.ts} +12 -26
  76. package/src/identity/hub/identityHubReducer.ts +3 -3
  77. package/src/identity/hub/{flows/profile → profile}/EditProfileFlow.tsx +17 -10
  78. package/src/identity/hub/{effects/publicProfile/runPublicProfileSave.ts → profile/effects.ts} +55 -177
  79. package/src/identity/hub/{model → profile}/identity.ts +3 -3
  80. package/src/identity/hub/{effects/profile/profileState.ts → profile/state.ts} +181 -173
  81. package/src/identity/hub/{flows/restore → restore}/RestoreFlow.tsx +21 -21
  82. package/src/identity/hub/{effects/restore → restore}/apply.ts +10 -10
  83. package/src/identity/hub/{effects/restore → restore}/auth.ts +7 -7
  84. package/src/identity/hub/{effects/restore → restore}/discover.ts +6 -6
  85. package/src/identity/hub/{effects/restore → restore}/envelopes.ts +2 -2
  86. package/src/identity/hub/{effects/restore → restore}/fetch.ts +3 -3
  87. package/src/identity/hub/{effects/restore/shared.ts → restore/helpers.ts} +6 -6
  88. package/src/identity/hub/{effects/restore → restore}/recovery.ts +10 -10
  89. package/src/identity/hub/{effects/restore → restore}/resolve.ts +4 -4
  90. package/src/identity/hub/restore/restoreAdmin.ts +34 -0
  91. package/src/identity/hub/{flows/restore/useRestoreFlowEffects.ts → restore/useRestoreEffects.ts} +5 -5
  92. package/src/identity/hub/{flows/settings → settings}/StorageCredentialScreen.tsx +5 -5
  93. package/src/identity/hub/{components → shared/components}/BusyScreen.tsx +4 -4
  94. package/src/identity/hub/{components → shared/components}/DetailsScreen.tsx +4 -4
  95. package/src/identity/hub/{components → shared/components}/ErrorScreen.tsx +4 -4
  96. package/src/identity/hub/{components → shared/components}/FlowTimeline.tsx +1 -1
  97. package/src/identity/hub/{components → shared/components}/IdentitySummary.tsx +16 -11
  98. package/src/identity/hub/{components → shared/components}/MenuScreen.tsx +8 -9
  99. package/src/identity/hub/{components → shared/components}/NetworkScreen.tsx +4 -4
  100. package/src/identity/hub/{components → shared/components}/PinataJwtInput.tsx +4 -4
  101. package/src/identity/hub/{components → shared/components}/UnlinkedIdentityScreen.tsx +5 -5
  102. package/src/identity/hub/{components → shared/components}/WalletApprovalScreen.tsx +6 -6
  103. package/src/identity/hub/{components → shared/components}/menuFlagsFromReconciliation.ts +2 -4
  104. package/src/identity/hub/{effects/shared → shared/effects}/profilePrep.ts +1 -1
  105. package/src/identity/hub/{effects → shared/effects}/receipts.ts +2 -2
  106. package/src/identity/hub/{effects/shared → shared/effects}/sync.ts +6 -47
  107. package/src/identity/hub/{effects → shared/effects}/types.ts +3 -3
  108. package/src/identity/hub/{model → shared/model}/copy.ts +2 -2
  109. package/src/identity/hub/{model → shared/model}/errors.ts +5 -5
  110. package/src/identity/hub/{model → shared/model}/network.ts +3 -3
  111. package/src/identity/hub/{operatorWallets.ts → shared/operatorWallets.ts} +1 -1
  112. package/src/identity/hub/{reconciliation → shared/reconciliation}/agentReconciliation/hook.ts +1 -2
  113. package/src/identity/hub/{reconciliation → shared/reconciliation}/agentReconciliation/ownership.ts +2 -2
  114. package/src/identity/hub/{reconciliation → shared/reconciliation}/agentReconciliation/run.ts +7 -40
  115. package/src/identity/hub/{reconciliation → shared/reconciliation}/agentReconciliation/types.ts +0 -4
  116. package/src/identity/hub/{reconciliation → shared/reconciliation}/index.ts +0 -7
  117. package/src/identity/hub/shared/reconciliation/walletSetup.ts +27 -0
  118. package/src/identity/hub/{utils.ts → shared/utils.ts} +5 -5
  119. package/src/identity/hub/{flows/token-transfer/IdentityHubTokenTransferFlow.tsx → transfer/TokenTransferFlow.tsx} +8 -8
  120. package/src/identity/hub/{flows/token-transfer → transfer}/TokenTransferScreens.tsx +14 -14
  121. package/src/identity/hub/{effects/token-transfer/runTokenTransfer.ts → transfer/effects.ts} +16 -16
  122. package/src/identity/hub/{effects/token-transfer → transfer}/progress.ts +1 -1
  123. package/src/identity/hub/useIdentityHubController.ts +11 -11
  124. package/src/identity/hub/useIdentityHubSideEffects.ts +11 -11
  125. package/src/identity/wallet/browserWallet/types.ts +0 -5
  126. package/src/identity/wallet/page/copy.ts +1 -31
  127. package/src/identity/wallet/walletPurposeCompat.ts +0 -2
  128. package/src/models/ModelPicker.tsx +248 -8
  129. package/src/models/catalog.ts +29 -1
  130. package/src/models/modelPickerOptions.ts +12 -10
  131. package/src/models/providerDisplay.ts +16 -0
  132. package/src/providers/errors.ts +6 -4
  133. package/src/providers/openai-chat.ts +2 -1
  134. package/src/providers/openai-responses-format.ts +156 -0
  135. package/src/providers/openai-responses.ts +276 -0
  136. package/src/providers/registry.ts +85 -8
  137. package/src/runtime/sessionMode.ts +1 -1
  138. package/src/runtime/systemPrompt.ts +4 -2
  139. package/src/runtime/toolExecution.ts +9 -6
  140. package/src/runtime/turn.ts +29 -1
  141. package/src/storage/rewind.ts +20 -0
  142. package/src/storage/secrets.ts +4 -1
  143. package/src/storage/sessions.ts +2 -1
  144. package/src/tools/bashSafety.ts +7 -3
  145. package/src/tools/bashTool.ts +1 -1
  146. package/src/tools/contracts.ts +3 -0
  147. package/src/tools/deleteFileTool.ts +8 -3
  148. package/src/tools/editTool.ts +10 -5
  149. package/src/tools/fileDiff.ts +261 -0
  150. package/src/tools/privateContinuityEditTool.ts +11 -1
  151. package/src/tools/writeFileTool.ts +8 -3
  152. package/src/ui/Spinner.tsx +25 -3
  153. package/src/ui/TextInput.tsx +2 -2
  154. package/src/ui/theme.ts +17 -0
  155. package/src/utils/clipboard.ts +10 -7
  156. package/src/utils/openExternal.ts +20 -10
  157. package/src/chat/RewindView.tsx +0 -386
  158. package/src/chat/toolResultDisplay.ts +0 -8
  159. package/src/identity/ens/ensRegistration.ts +0 -199
  160. package/src/identity/hub/effects/index.ts +0 -74
  161. package/src/identity/hub/effects/publicProfile/index.ts +0 -5
  162. package/src/identity/hub/effects/restore/restoreEffects.ts +0 -22
  163. package/src/identity/hub/effects/restoreAdmin.ts +0 -93
  164. package/src/identity/hub/effects/token-transfer/index.ts +0 -6
  165. package/src/identity/hub/flows/ens/EnsEditAdvancedScreens.tsx +0 -336
  166. package/src/identity/hub/flows/ens/EnsEditRunners.tsx +0 -198
  167. package/src/identity/hub/reconciliation/walletSetup.ts +0 -220
  168. /package/src/chat/{chatInputState.ts → input/chatInputState.ts} +0 -0
  169. /package/src/chat/{chatPaste.ts → input/chatPaste.ts} +0 -0
  170. /package/src/chat/{textCursor.ts → input/textCursor.ts} +0 -0
  171. /package/src/identity/hub/{model/continuity.ts → continuity/state.ts} +0 -0
  172. /package/src/identity/hub/{model/custody.ts → custody/state.ts} +0 -0
  173. /package/src/identity/hub/{effects/restore → restore}/index.ts +0 -0
  174. /package/src/identity/hub/{model → shared/model}/format.ts +0 -0
  175. /package/src/identity/hub/{reconciliation → shared/reconciliation}/useAgentReconciliation.ts +0 -0
  176. /package/src/identity/hub/{txGuard.ts → shared/txGuard.ts} +0 -0
  177. /package/src/identity/hub/{model/transfer.ts → transfer/state.ts} +0 -0
@@ -1,199 +0,0 @@
1
- import {
2
- encodeAbiParameters,
3
- encodeFunctionData,
4
- getAddress,
5
- keccak256,
6
- namehash,
7
- parseAbi,
8
- type Address,
9
- type Hex,
10
- type PublicClient,
11
- } from 'viem'
12
-
13
- export const ETH_REGISTRAR_CONTROLLER_MAINNET = '0x253553366Da8546fC250F225fe3d25d0C782303b' as Address
14
- export const PUBLIC_RESOLVER_MAINNET = '0x231b0Ee14048e9dCcD1d247744d114a4EB5E8E63' as Address
15
- export const MIN_COMMIT_AGE_SECONDS = 60
16
- export const MAX_COMMIT_AGE_SECONDS = 86_400
17
- export const ONE_YEAR_SECONDS = 31_557_600
18
- export const REGISTER_VALUE_BUFFER_BIPS = 500n
19
-
20
- const CONTROLLER_ABI = parseAbi([
21
- 'function available(string name) view returns (bool)',
22
- 'function rentPrice(string name, uint256 duration) view returns (uint256 base, uint256 premium)',
23
- 'function commit(bytes32 commitment)',
24
- 'function register(string name, address owner, uint256 duration, bytes32 secret, address resolver, bytes[] data, bool reverseRecord, uint16 ownerControlledFuses) payable',
25
- ])
26
-
27
- const RESOLVER_ABI = parseAbi([
28
- 'function setAddr(bytes32 node, address a)',
29
- ])
30
-
31
- export type RegistrableNameValidation =
32
- | { ok: true; label: string }
33
- | { ok: false; reason: 'too-short' | 'too-long' | 'invalid-characters' | 'leading-hyphen' | 'trailing-hyphen' | 'contains-dot'; detail: string }
34
-
35
- export function validateRegistrableName(value: string): RegistrableNameValidation {
36
- const label = value.trim().toLowerCase()
37
- if (label.includes('.')) {
38
- return { ok: false, reason: 'contains-dot', detail: 'Enter only the label, not a full .eth name.' }
39
- }
40
- if (label.length < 3) {
41
- return { ok: false, reason: 'too-short', detail: 'Names must be at least 3 characters.' }
42
- }
43
- if (label.length > 64) {
44
- return { ok: false, reason: 'too-long', detail: 'Names must be 64 characters or fewer.' }
45
- }
46
- if (label.startsWith('-')) {
47
- return { ok: false, reason: 'leading-hyphen', detail: 'Names cannot start with a hyphen.' }
48
- }
49
- if (label.endsWith('-')) {
50
- return { ok: false, reason: 'trailing-hyphen', detail: 'Names cannot end with a hyphen.' }
51
- }
52
- if (!/^[a-z0-9-]+$/.test(label)) {
53
- return { ok: false, reason: 'invalid-characters', detail: 'Names use lowercase letters, numbers, and hyphens only.' }
54
- }
55
- return { ok: true, label }
56
- }
57
-
58
- type RentPrice = {
59
- base: bigint
60
- premium: bigint
61
- total: bigint
62
- }
63
-
64
- export type EnsRegistrationReadClient = Pick<PublicClient, 'readContract'>
65
-
66
- export async function readRentPrice(
67
- client: EnsRegistrationReadClient,
68
- label: string,
69
- durationSeconds: bigint,
70
- ): Promise<RentPrice> {
71
- const result = await client.readContract({
72
- address: ETH_REGISTRAR_CONTROLLER_MAINNET,
73
- abi: CONTROLLER_ABI,
74
- functionName: 'rentPrice',
75
- args: [label, durationSeconds],
76
- }) as readonly [bigint, bigint]
77
- const [base, premium] = result
78
- return { base, premium, total: base + premium }
79
- }
80
-
81
- export async function readNameAvailable(
82
- client: EnsRegistrationReadClient,
83
- label: string,
84
- ): Promise<boolean> {
85
- return await client.readContract({
86
- address: ETH_REGISTRAR_CONTROLLER_MAINNET,
87
- abi: CONTROLLER_ABI,
88
- functionName: 'available',
89
- args: [label],
90
- }) as boolean
91
- }
92
-
93
- type CommitmentArgs = {
94
- label: string
95
- owner: Address
96
- durationSeconds: bigint
97
- secret: Hex
98
- resolver?: Address
99
- setAddrToOwner?: boolean
100
- reverseRecord?: boolean
101
- ownerControlledFuses?: number
102
- }
103
-
104
- type CommitmentBuild = {
105
- commitment: Hex
106
- resolver: Address
107
- data: Hex[]
108
- reverseRecord: boolean
109
- ownerControlledFuses: number
110
- }
111
-
112
- export function buildCommitment(args: CommitmentArgs): CommitmentBuild {
113
- const owner = getAddress(args.owner)
114
- const resolver = getAddress(args.resolver ?? PUBLIC_RESOLVER_MAINNET)
115
- const reverseRecord = args.reverseRecord ?? false
116
- const ownerControlledFuses = args.ownerControlledFuses ?? 0
117
- const data: Hex[] = []
118
- if (args.setAddrToOwner ?? true) {
119
- data.push(encodeFunctionData({
120
- abi: RESOLVER_ABI,
121
- functionName: 'setAddr',
122
- args: [namehash(`${args.label}.eth`), owner],
123
- }))
124
- }
125
- const commitment = keccak256(encodeAbiParameters(
126
- [
127
- { type: 'string' },
128
- { type: 'address' },
129
- { type: 'uint256' },
130
- { type: 'bytes32' },
131
- { type: 'address' },
132
- { type: 'bytes[]' },
133
- { type: 'bool' },
134
- { type: 'uint16' },
135
- ],
136
- [args.label, owner, args.durationSeconds, args.secret, resolver, data, reverseRecord, ownerControlledFuses],
137
- ))
138
- return { commitment, resolver, data, reverseRecord, ownerControlledFuses }
139
- }
140
-
141
- export function encodeCommitTransaction(commitment: Hex): { to: Address; data: Hex } {
142
- return {
143
- to: ETH_REGISTRAR_CONTROLLER_MAINNET,
144
- data: encodeFunctionData({
145
- abi: CONTROLLER_ABI,
146
- functionName: 'commit',
147
- args: [commitment],
148
- }),
149
- }
150
- }
151
-
152
- type RegisterTransactionArgs = {
153
- label: string
154
- owner: Address
155
- durationSeconds: bigint
156
- secret: Hex
157
- rentPrice: RentPrice
158
- resolver?: Address
159
- setAddrToOwner?: boolean
160
- reverseRecord?: boolean
161
- ownerControlledFuses?: number
162
- }
163
-
164
- export function encodeRegisterTransaction(args: RegisterTransactionArgs): { to: Address; data: Hex; value: Hex } {
165
- const owner = getAddress(args.owner)
166
- const built = buildCommitment({
167
- label: args.label,
168
- owner,
169
- durationSeconds: args.durationSeconds,
170
- secret: args.secret,
171
- ...(args.resolver !== undefined ? { resolver: args.resolver } : {}),
172
- ...(args.setAddrToOwner !== undefined ? { setAddrToOwner: args.setAddrToOwner } : {}),
173
- ...(args.reverseRecord !== undefined ? { reverseRecord: args.reverseRecord } : {}),
174
- ...(args.ownerControlledFuses !== undefined ? { ownerControlledFuses: args.ownerControlledFuses } : {}),
175
- })
176
- const data = encodeFunctionData({
177
- abi: CONTROLLER_ABI,
178
- functionName: 'register',
179
- args: [args.label, owner, args.durationSeconds, args.secret, built.resolver, built.data, built.reverseRecord, built.ownerControlledFuses],
180
- })
181
- const buffered = (args.rentPrice.total * (10000n + REGISTER_VALUE_BUFFER_BIPS)) / 10000n
182
- return {
183
- to: ETH_REGISTRAR_CONTROLLER_MAINNET,
184
- data,
185
- value: ('0x' + buffered.toString(16)) as Hex,
186
- }
187
- }
188
-
189
- export function generateRegistrationSecret(): Hex {
190
- const bytes = new Uint8Array(32)
191
- if (typeof globalThis.crypto?.getRandomValues === 'function') {
192
- globalThis.crypto.getRandomValues(bytes)
193
- } else {
194
- for (let i = 0; i < bytes.length; i++) bytes[i] = Math.floor(Math.random() * 256)
195
- }
196
- let hex = '0x'
197
- for (const byte of bytes) hex += byte.toString(16).padStart(2, '0')
198
- return hex as Hex
199
- }
@@ -1,74 +0,0 @@
1
- export type {
2
- CustodySwitchAdvancedProgress,
3
- EffectCallbacks,
4
- EnsClearProgress,
5
- EnsLinkProgress,
6
- EnsUpdateProgress,
7
- IdentityCompletionSource,
8
- RestoreProgress,
9
- TokenTransferProgress,
10
- } from './types.js'
11
- export { awaitConfirmedReceipt } from './receipts.js'
12
- export {
13
- ensRecordWritesForUpdate,
14
- runEnsLinkFlow,
15
- runEnsSetupRecordsTransaction,
16
- runEnsSetupRegistryTransaction,
17
- runEnsUnlinkFlow,
18
- runEnsUpdateFlow,
19
- runUpdateEnsRecords,
20
- } from './ens/index.js'
21
- export {
22
- applyEnsValidationState,
23
- applyOperatorProfileState,
24
- } from './profile/profileState.js'
25
- export {
26
- canRestoreCandidate,
27
- resolveAgentEnsToCandidate,
28
- resolveAgentTokenIdToCandidate,
29
- restoreSignatureRequestForStep,
30
- restoreTokenSelectionStep,
31
- runRecoveryRefetch,
32
- runRestoreAuthorize,
33
- runRestoreConnectWallet,
34
- runRestoreDiscover,
35
- runRestoreFetch,
36
- } from './restore/restoreEffects.js'
37
- export {
38
- assertTokenNotInVault,
39
- VaultUnavailableError,
40
- TokenInVaultError,
41
- } from './vault/preflight.js'
42
- export {
43
- createContinuityEnvelopeForSave,
44
- expectedAccountForSnapshotSave,
45
- snapshotSaveRequiresOwnerSigner,
46
- snapshotSaveWalletRole,
47
- } from './shared/snapshot.js'
48
- export {
49
- runCreatePreflight,
50
- runCreateSigning,
51
- runRegistrySubmit,
52
- runStorageSubmit,
53
- } from './create.js'
54
- export {
55
- runFixRecordsSubmit,
56
- runRestoreRegistrySubmit,
57
- } from './restoreAdmin.js'
58
- export {
59
- runPublicProfilePreflight,
60
- runPublicProfileSigning,
61
- runPublicProfileStorageSubmit,
62
- } from './publicProfile/runPublicProfileSave.js'
63
- export {
64
- runRebackupPreflight,
65
- runRebackupSigning,
66
- runRebackupSigningInSession,
67
- runRebackupStorageSubmit,
68
- } from './rebackup/runRebackup.js'
69
- export {
70
- tokenTransferProgressForPhase,
71
- runTokenTransferSigning,
72
- runTokenTransferStorageSubmit,
73
- runTokenTransferTargetSubmit,
74
- } from './token-transfer/runTokenTransfer.js'
@@ -1,5 +0,0 @@
1
- export {
2
- runPublicProfilePreflight,
3
- runPublicProfileSigning,
4
- runPublicProfileStorageSubmit,
5
- } from './runPublicProfileSave.js'
@@ -1,22 +0,0 @@
1
- export {
2
- canRestoreCandidate,
3
- restoreTokenSelectionStep,
4
- runRestoreDiscover,
5
- } from './discover.js'
6
- export {
7
- resolveAgentEnsToCandidate,
8
- resolveAgentTokenIdToCandidate,
9
- } from './resolve.js'
10
- export {
11
- restoreSignatureRequestForStep,
12
- runRestoreConnectWallet,
13
- } from './auth.js'
14
- export {
15
- runRestoreFetch,
16
- } from './fetch.js'
17
- export {
18
- runRestoreAuthorize,
19
- } from './apply.js'
20
- export {
21
- runRecoveryRefetch,
22
- } from './recovery.js'
@@ -1,93 +0,0 @@
1
- import { getAddress, type Address } from 'viem'
2
- import type { EthagentConfig, EthagentIdentity } from '../../../storage/config.js'
3
- import { saveConfig } from '../../../storage/config.js'
4
- import {
5
- normalizeErc8004RegistryConfig,
6
- type Erc8004RegistryConfig,
7
- } from '../../registry/erc8004.js'
8
- import { registryConfigFromConfig } from '../../registry/registryConfig.js'
9
- import { readOwnerAddressField } from '../../identityCompat.js'
10
- import {
11
- sendBrowserWalletTransaction,
12
- } from '../../wallet/browserWallet.js'
13
- import {
14
- encodeResolverApprovalChanges,
15
- verifyResolverApprovalsLanded,
16
- type RecordsFixPlan,
17
- } from '../reconciliation/index.js'
18
- import type { Step } from '../identityHubReducer.js'
19
- import type { EffectCallbacks } from './types.js'
20
- import { awaitOptionalReceipt } from './receipts.js'
21
- import { createMainnetEnsPublicClient } from './ens/transactions.js'
22
-
23
- export async function runRestoreRegistrySubmit(
24
- value: string,
25
- step: Extract<Step, { kind: 'restore-registry' }>,
26
- config: EthagentConfig | undefined,
27
- onConfigChange: ((config: EthagentConfig) => void) | undefined,
28
- callbacks: EffectCallbacks,
29
- ): Promise<void> {
30
- const resolution = registryConfigFromConfig(config)
31
- const registry = normalizeErc8004RegistryConfig({
32
- chainId: resolution.chainId,
33
- rpcUrl: resolution.config?.rpcUrl ?? resolution.defaultRpcUrl,
34
- identityRegistryAddress: value.trim(),
35
- })
36
- if (config && onConfigChange) {
37
- const next: EthagentConfig = {
38
- ...config,
39
- erc8004: {
40
- chainId: registry.chainId,
41
- rpcUrl: registry.rpcUrl,
42
- identityRegistryAddress: registry.identityRegistryAddress,
43
- },
44
- }
45
- await saveConfig(next)
46
- onConfigChange(next)
47
- }
48
- callbacks.onStep({ kind: 'restore-discovering', ownerHandle: step.ownerHandle, registry, purpose: step.purpose })
49
- }
50
-
51
- export async function runFixRecordsSubmit(args: {
52
- identity: EthagentIdentity
53
- registry: Erc8004RegistryConfig
54
- plan: RecordsFixPlan
55
- callbacks: EffectCallbacks
56
- }): Promise<void> {
57
- const baseState = (args.identity.state ?? {}) as Record<string, unknown>
58
- const ensName = args.plan.ensName ?? (typeof baseState.ensName === 'string' ? baseState.ensName.trim() : '')
59
- if (!ensName) throw new Error('Cannot fix records: identity has no ENS subdomain')
60
- const missing: Address[] = []
61
- const stale: Address[] = []
62
- for (const item of args.plan.items) {
63
- if (item.kind === 'missing-approval') missing.push(item.address)
64
- else if (item.kind === 'stale-approval') stale.push(item.address)
65
- }
66
- if (missing.length === 0 && stale.length === 0) return
67
- const encoded = await encodeResolverApprovalChanges({
68
- ensName,
69
- diff: { added: missing, removed: stale },
70
- })
71
- if (!encoded) return
72
- const ownerAddressRaw = readOwnerAddressField(baseState) ?? args.identity.ownerAddress ?? args.identity.address
73
- const ownerAddress = getAddress(ownerAddressRaw)
74
- const tx = await sendBrowserWalletTransaction({
75
- chainId: 1,
76
- expectedAccount: ownerAddress,
77
- to: encoded.resolverAddress,
78
- data: encoded.data,
79
- onReady: args.callbacks.onWalletReady,
80
- purpose: 'reconcile-resolver-approvals',
81
- })
82
- args.callbacks.onWalletReady(null)
83
- const client = createMainnetEnsPublicClient()
84
- await awaitOptionalReceipt(client, tx.txHash, 'Resolver approval reconciliation')
85
- await verifyResolverApprovalsLanded({
86
- ensName,
87
- ownerAddress: ownerAddress,
88
- resolverAddress: encoded.resolverAddress,
89
- added: encoded.added,
90
- removed: encoded.removed,
91
- client,
92
- })
93
- }
@@ -1,6 +0,0 @@
1
- export {
2
- runTokenTransferSigning,
3
- runTokenTransferStorageSubmit,
4
- runTokenTransferTargetSubmit,
5
- tokenTransferProgressForPhase,
6
- } from './runTokenTransfer.js'