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,220 +0,0 @@
1
- import {
2
- createPublicClient,
3
- encodeFunctionData,
4
- fallback,
5
- getAddress,
6
- http,
7
- namehash,
8
- type Address,
9
- type Hex,
10
- type PublicClient,
11
- } from 'viem'
12
- import { mainnet } from 'viem/chains'
13
- import type { EthagentIdentity } from '../../../storage/config.js'
14
- import type { Erc8004RegistryConfig } from '../../registry/erc8004.js'
15
- import { ENS_AUTOMATION_RESOLVER_ABI } from '../../ens/ensAutomation.js'
16
- import { encodeApprove, encodeApprovalRevoke, readDelegation } from '../../ens/resolverDelegation.js'
17
- import { readResolverAddress } from '../../ens/ensLookup.js'
18
- import { normalizeApprovedOperatorWallets } from '../operatorWallets.js'
19
- import { readCustodyMode } from '../model/custody.js'
20
- import { readOwnerAddressField } from '../../identityCompat.js'
21
-
22
- export type ApprovalDiff = {
23
- added: Address[]
24
- removed: Address[]
25
- }
26
-
27
- export function computeApprovalDiff(
28
- beforeApproved: ReadonlyArray<{ address: string }>,
29
- afterApproved: ReadonlyArray<{ address: string }>,
30
- ): ApprovalDiff {
31
- const before = new Set(beforeApproved.map(record => record.address.toLowerCase()))
32
- const after = new Set(afterApproved.map(record => record.address.toLowerCase()))
33
- const added: Address[] = []
34
- const removed: Address[] = []
35
- for (const record of afterApproved) {
36
- if (!before.has(record.address.toLowerCase())) {
37
- added.push(getAddress(record.address))
38
- }
39
- }
40
- for (const record of beforeApproved) {
41
- if (!after.has(record.address.toLowerCase())) {
42
- removed.push(getAddress(record.address))
43
- }
44
- }
45
- return { added, removed }
46
- }
47
-
48
- type ResolverApprovalCalls = {
49
- resolverAddress: Address
50
- data: Hex
51
- calls: Hex[]
52
- added: Address[]
53
- removed: Address[]
54
- }
55
-
56
- export async function encodeResolverApprovalChanges(args: {
57
- ensName: string
58
- diff: ApprovalDiff
59
- }): Promise<ResolverApprovalCalls | null> {
60
- if (args.diff.added.length === 0 && args.diff.removed.length === 0) return null
61
- const resolverAddress = await readResolverAddress(args.ensName)
62
- if (!resolverAddress) {
63
- throw new Error(`no resolver set on ${args.ensName} - finish ENS subdomain setup first`)
64
- }
65
- const node = namehash(args.ensName)
66
- const calls: Hex[] = []
67
- for (const address of args.diff.added) calls.push(encodeApprove(node, address))
68
- for (const address of args.diff.removed) calls.push(encodeApprovalRevoke(node, address))
69
- const data = calls.length === 1
70
- ? calls[0]!
71
- : encodeFunctionData({
72
- abi: ENS_AUTOMATION_RESOLVER_ABI,
73
- functionName: 'multicall',
74
- args: [calls],
75
- })
76
- return {
77
- resolverAddress,
78
- data,
79
- calls,
80
- added: args.diff.added,
81
- removed: args.diff.removed,
82
- }
83
- }
84
-
85
- export type RecordsFixPlanItem =
86
- | { kind: 'missing-approval'; address: Address }
87
- | { kind: 'stale-approval'; address: Address }
88
- | { kind: 'no-resolver' }
89
- | { kind: 'no-ens' }
90
-
91
- export type RecordsFixPlan = {
92
- identityAgentId: string
93
- ensName: string | undefined
94
- items: RecordsFixPlanItem[]
95
- }
96
-
97
- type ReconcileArgs = {
98
- identity: EthagentIdentity
99
- registry: Erc8004RegistryConfig
100
- client?: Pick<PublicClient, 'readContract'>
101
- }
102
-
103
- export async function reconcileWalletSetup(
104
- args: ReconcileArgs,
105
- ): Promise<RecordsFixPlan> {
106
- const baseState = (args.identity.state ?? {}) as Record<string, unknown>
107
- const ensName = typeof baseState.ensName === 'string' ? baseState.ensName.trim() : ''
108
- const custodyMode = readCustodyMode(baseState)
109
- const approved = normalizeApprovedOperatorWallets(baseState.approvedOperatorWallets)
110
- const items: RecordsFixPlanItem[] = []
111
-
112
- if (custodyMode !== 'advanced' || approved.length === 0) {
113
- return { identityAgentId: String(args.identity.agentId ?? ''), ensName: ensName || undefined, items }
114
- }
115
- if (!ensName) {
116
- items.push({ kind: 'no-ens' })
117
- return { identityAgentId: String(args.identity.agentId ?? ''), ensName: undefined, items }
118
- }
119
-
120
- let resolverAddress: Address | null
121
- try {
122
- resolverAddress = await readResolverAddress(ensName)
123
- } catch {
124
- resolverAddress = null
125
- }
126
- if (!resolverAddress) {
127
- items.push({ kind: 'no-resolver' })
128
- return { identityAgentId: String(args.identity.agentId ?? ''), ensName, items }
129
- }
130
-
131
- const ownerAddress = readOwnerAddressField(baseState) ?? args.identity.ownerAddress ?? args.identity.address
132
- const node = namehash(ensName)
133
-
134
- for (const record of approved) {
135
- const isApproved = await readDelegation({
136
- client: args.client ?? createReadClient(),
137
- resolverAddress,
138
- ownerAddress: getAddress(ownerAddress),
139
- node,
140
- delegateAddress: getAddress(record.address),
141
- })
142
- if (!isApproved) {
143
- items.push({ kind: 'missing-approval', address: getAddress(record.address) })
144
- }
145
- }
146
-
147
- return { identityAgentId: String(args.identity.agentId ?? ''), ensName, items }
148
- }
149
-
150
- function createReadClient(): Pick<PublicClient, 'readContract'> {
151
- const transports = [
152
- http('https://ethereum.publicnode.com', { retryCount: 0, timeout: 8_000 }),
153
- http('https://eth.llamarpc.com', { retryCount: 0, timeout: 8_000 }),
154
- ]
155
- return createPublicClient({
156
- chain: mainnet,
157
- transport: fallback(transports, { retryCount: 0 }),
158
- })
159
- }
160
-
161
- type VerifyResolverApprovalsArgs = {
162
- ensName: string
163
- ownerAddress: Address
164
- resolverAddress: Address
165
- added: ReadonlyArray<Address>
166
- removed: ReadonlyArray<Address>
167
- client?: Pick<PublicClient, 'readContract'>
168
- }
169
-
170
- export async function verifyResolverApprovalsLanded(args: VerifyResolverApprovalsArgs): Promise<void> {
171
- if (args.added.length === 0 && args.removed.length === 0) return
172
- const client = args.client ?? createReadClient()
173
- const node = namehash(args.ensName)
174
- const owner = getAddress(args.ownerAddress)
175
- for (const address of args.added) {
176
- const delegate = getAddress(address)
177
- const isApproved = await readDelegation({
178
- client,
179
- resolverAddress: args.resolverAddress,
180
- ownerAddress: owner,
181
- node,
182
- delegateAddress: delegate,
183
- })
184
- if (!isApproved) {
185
- throw new Error(`Resolver delegation didn't land for operator wallet ${delegate}. Your wallet may have rejected the inner operation; retry by selecting Fix Records again.`)
186
- }
187
- }
188
- for (const address of args.removed) {
189
- const delegate = getAddress(address)
190
- const isApproved = await readDelegation({
191
- client,
192
- resolverAddress: args.resolverAddress,
193
- ownerAddress: owner,
194
- node,
195
- delegateAddress: delegate,
196
- })
197
- if (isApproved) {
198
- throw new Error(`Resolver revocation didn't land for operator wallet ${delegate}. Your wallet may have rejected the inner operation; retry by selecting Fix Records again.`)
199
- }
200
- }
201
- }
202
-
203
- export function fixPlanRequiresOwnerWallet(plan: RecordsFixPlan): boolean {
204
- return plan.items.some(item =>
205
- item.kind === 'missing-approval' || item.kind === 'stale-approval',
206
- )
207
- }
208
-
209
- export function describeFixPlanItem(item: RecordsFixPlanItem): string {
210
- switch (item.kind) {
211
- case 'missing-approval':
212
- return `operator wallet ${item.address} has no onchain resolver approval, record writes will be rejected`
213
- case 'stale-approval':
214
- return `operator wallet ${item.address} has an onchain approval that no longer matches the operator set`
215
- case 'no-resolver':
216
- return 'ENS subdomain has no resolver set yet, finish ENS setup before authorizing operator wallets onchain'
217
- case 'no-ens':
218
- return 'advanced mode requires an ENS subdomain so operator wallets can sign profile updates onchain'
219
- }
220
- }
File without changes
File without changes