|
23 | 23 | import { createLogger } from '@sim/logger' |
24 | 24 | import { mapWithConcurrency } from '@sim/utils/concurrency' |
25 | 25 | import { getErrorMessage } from '@sim/utils/errors' |
26 | | -import { isRecordLike } from '@sim/utils/object' |
27 | | -import { didYouMean, type Json, type SourceSpan } from '@sim/workflow-code' |
| 26 | +import { didYouMean, type SourceSpan } from '@sim/workflow-code' |
28 | 27 | import { SOURCE_ENTRY_FILE } from '@sim/workflow-code/limits' |
29 | 28 | import { |
30 | 29 | type BaseResource, |
@@ -75,6 +74,7 @@ import { |
75 | 74 | resolveStoredHeaders, |
76 | 75 | storedFingerprint, |
77 | 76 | } from '@/lib/workspace-source/application/kinds/mcp/stored' |
| 77 | +import { changedFields } from '@/lib/workspace-source/application/kinds/named' |
78 | 78 | import { |
79 | 79 | holdsIn, |
80 | 80 | refuseUnreadAdopt, |
@@ -122,16 +122,6 @@ function serverIdOf(ctx: SourceContext, url: string): string { |
122 | 122 | return generateMcpServerId(ctx.workspace.workspaceId, url) |
123 | 123 | } |
124 | 124 |
|
125 | | -/** The top-level declaration fields whose canonical values differ. */ |
126 | | -function changedFields(before: McpServerDecl, after: McpServerDecl): string[] { |
127 | | - const a = mcpCodec.canonical(before) |
128 | | - const b = mcpCodec.canonical(after) |
129 | | - if (!isRecordLike(a) || !isRecordLike(b)) return [] |
130 | | - return Object.keys(b).filter( |
131 | | - (field) => fingerprintOf(b[field] as Json) !== fingerprintOf(a[field] as Json) |
132 | | - ) |
133 | | -} |
134 | | - |
135 | 125 | function baseOf(record: StoredServer): BaseResource { |
136 | 126 | return { id: record.id, fingerprint: storedFingerprint(record.state) } |
137 | 127 | } |
@@ -243,7 +233,7 @@ async function planServer( |
243 | 233 | } |
244 | 234 | } |
245 | 235 | const record = planned.stored |
246 | | - const changed = changedFields(declOf(record.state), decl) |
| 236 | + const changed = changedFields(mcpCodec.canonical(declOf(record.state)), mcpCodec.canonical(decl)) |
247 | 237 | if (planned.action === 'adopt' && !resumed) { |
248 | 238 | const refused = refuseUnreadAdopt(change, record, changed) |
249 | 239 | if (refused) return refused |
|
0 commit comments