@deepseek-harness-tui/dsh-tui 0.9.2 → 0.9.3
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.
- package/README.md +4 -4
- package/bin/dsh-tui.js +26 -4
- package/dsh-ecosystem-spec/protocols/profile-definitions.d.ts +13 -13
- package/dsh-ecosystem-spec/protocols/profile-definitions.js +59 -59
- package/dsh-ecosystem-spec/protocols/tui-channel-http.d.ts +15 -15
- package/dsh-ecosystem-spec/protocols/tui-channel-http.js +32 -32
- package/dsh-ecosystem-spec/protocols/tui-channel.d.ts +59 -59
- package/dsh-ecosystem-spec/protocols/tui-channel.js +166 -166
- package/dsh-ecosystem-spec/protocols/tui-contributions.d.ts +42 -42
- package/dsh-ecosystem-spec/protocols/tui-contributions.js +143 -143
- package/dsh-ecosystem-spec/registry/README.md +14 -14
- package/dsh-ecosystem-spec/registry/host-descriptor.tui.example.json +56 -56
- package/dsh-ecosystem-spec/registry/permissions-0.1.json +13 -13
- package/dsh-ecosystem-spec/registry/registry-0.15.json +149 -149
- package/lib/types/commands.d.ts.map +1 -1
- package/lib/types/commands.js +7 -8
- package/lib/types/components/BalanceReportRow.d.ts +24 -0
- package/lib/types/components/BalanceReportRow.d.ts.map +1 -0
- package/lib/types/components/BalanceReportRow.js +87 -0
- package/lib/types/components/HistorySearchDialog.js +1 -1
- package/lib/types/components/MessageList.d.ts +3 -1
- package/lib/types/components/MessageList.d.ts.map +1 -1
- package/lib/types/components/MessageList.js +11 -7
- package/lib/types/components/PluginSceneBoundary.d.ts +1 -1
- package/lib/types/components/PluginSceneBoundary.js +1 -1
- package/lib/types/components/PromptInput.d.ts.map +1 -1
- package/lib/types/components/PromptInput.js +16 -0
- package/lib/types/components/Whale.d.ts +15 -4
- package/lib/types/components/Whale.d.ts.map +1 -1
- package/lib/types/components/Whale.js +9 -8
- package/lib/types/components/messages/AssistantToolUseMessage.d.ts +7 -1
- package/lib/types/components/messages/AssistantToolUseMessage.d.ts.map +1 -1
- package/lib/types/components/messages/AssistantToolUseMessage.js +34 -4
- package/lib/types/deepseekBalance.d.ts +53 -0
- package/lib/types/deepseekBalance.d.ts.map +1 -0
- package/lib/types/deepseekBalance.js +86 -0
- package/lib/types/deepseekPricing.d.ts +82 -0
- package/lib/types/deepseekPricing.d.ts.map +1 -0
- package/lib/types/deepseekPricing.js +133 -0
- package/lib/types/dsh-adapter/channel.d.ts +46 -1
- package/lib/types/dsh-adapter/channel.d.ts.map +1 -1
- package/lib/types/dsh-adapter/channel.js +84 -10
- package/lib/types/dsh-adapter/index.d.ts +5 -0
- package/lib/types/dsh-adapter/index.d.ts.map +1 -1
- package/lib/types/dsh-adapter/index.js +1 -0
- package/lib/types/dsh-adapter/packaged-skills.d.ts +9 -0
- package/lib/types/dsh-adapter/packaged-skills.d.ts.map +1 -1
- package/lib/types/dsh-adapter/packaged-skills.js +19 -4
- package/lib/types/dsh-adapter/plugin.d.ts +6 -0
- package/lib/types/dsh-adapter/plugin.d.ts.map +1 -1
- package/lib/types/dsh-adapter/plugin.js +122 -18
- package/lib/types/dsh-adapter/settings-sections.d.ts +1 -0
- package/lib/types/dsh-adapter/settings-sections.d.ts.map +1 -1
- package/lib/types/dsh-adapter/settings-sections.js +35 -2
- package/lib/types/history.d.ts +4 -3
- package/lib/types/history.d.ts.map +1 -1
- package/lib/types/history.js +66 -18
- package/lib/types/i18n.d.ts +122 -55
- package/lib/types/i18n.d.ts.map +1 -1
- package/lib/types/i18n.js +39 -18
- package/lib/types/ink/ink.d.ts.map +1 -1
- package/lib/types/ink/ink.js +67 -17
- package/lib/types/ink/root.d.ts +16 -0
- package/lib/types/ink/root.d.ts.map +1 -1
- package/lib/types/ink/root.js +2 -0
- package/lib/types/ink/terminal-querier.d.ts +8 -0
- package/lib/types/ink/terminal-querier.d.ts.map +1 -1
- package/lib/types/ink/terminal-querier.js +13 -0
- package/lib/types/ink/terminal.d.ts +42 -0
- package/lib/types/ink/terminal.d.ts.map +1 -1
- package/lib/types/ink/terminal.js +52 -2
- package/lib/types/plugin-spec/registry.d.ts +1 -1
- package/lib/types/plugin-spec/registry.js +1 -1
- package/lib/types/screens/Chat.d.ts.map +1 -1
- package/lib/types/screens/Chat.js +72 -37
- package/lib/types/screens/SessionBrowser.d.ts.map +1 -1
- package/lib/types/screens/SessionBrowser.js +28 -13
- package/lib/types/screens/SessionTree.d.ts.map +1 -1
- package/lib/types/screens/SessionTree.js +33 -9
- package/lib/types/screens/Settings.d.ts +7 -5
- package/lib/types/screens/Settings.d.ts.map +1 -1
- package/lib/types/screens/Settings.js +206 -99
- package/lib/types/screens/StatusLine.d.ts.map +1 -1
- package/lib/types/screens/StatusLine.js +32 -1
- package/lib/types/sessionHistory.d.ts +11 -0
- package/lib/types/sessionHistory.d.ts.map +1 -1
- package/lib/types/sessionHistory.js +29 -0
- package/lib/types/sessions/format.d.ts.map +1 -1
- package/lib/types/sessions/format.js +14 -4
- package/lib/types/tips.js +2 -2
- package/lib/types/tuiDisplayPrefs.d.ts +3 -0
- package/lib/types/tuiDisplayPrefs.d.ts.map +1 -1
- package/lib/types/tuiDisplayPrefs.js +1 -0
- package/lib/types/update.d.ts +46 -0
- package/lib/types/update.d.ts.map +1 -1
- package/lib/types/update.js +232 -3
- package/node_modules/@deepseek-harness-tui/dsh-auth/LICENSE +21 -21
- package/node_modules/@deepseek-harness-tui/dsh-auth/dsh-plugin.json +44 -44
- package/node_modules/@dsh-std/command/CHANGELOG.md +8 -8
- package/node_modules/@dsh-std/command/LICENSE +21 -21
- package/node_modules/@dsh-std/command/README.md +26 -26
- package/node_modules/@dsh-std/command/README.zh.md +28 -28
- package/node_modules/@dsh-std/command/lib/index.js.map +1 -1
- package/node_modules/@dsh-std/command/package.json +22 -22
- package/node_modules/@dsh-std/connection/CHANGELOG.md +8 -8
- package/node_modules/@dsh-std/connection/LICENSE +21 -21
- package/node_modules/@dsh-std/connection/README.md +42 -42
- package/node_modules/@dsh-std/connection/README.zh.md +42 -42
- package/node_modules/@dsh-std/connection/lib/index.js.map +1 -1
- package/node_modules/@dsh-std/connection/lib/memory.js.map +1 -1
- package/node_modules/@dsh-std/connection/lib/resolve-3X6ausgz.js.map +1 -1
- package/node_modules/@dsh-std/connection/package.json +20 -20
- package/node_modules/@dsh-std/core/CHANGELOG.md +8 -8
- package/node_modules/@dsh-std/core/LICENSE +21 -21
- package/node_modules/@dsh-std/core/README.md +13 -13
- package/node_modules/@dsh-std/core/README.zh.md +13 -13
- package/node_modules/@dsh-std/core/lib/index.js.map +1 -1
- package/node_modules/@dsh-std/core/package.json +21 -21
- package/node_modules/@dsh-std/manifest/CHANGELOG.md +9 -9
- package/node_modules/@dsh-std/manifest/LICENSE +21 -21
- package/node_modules/@dsh-std/manifest/README.md +5 -5
- package/node_modules/@dsh-std/manifest/README.zh.md +5 -5
- package/node_modules/@dsh-std/manifest/lib/index.js.map +1 -1
- package/node_modules/@dsh-std/manifest/package.json +20 -20
- package/node_modules/@dsh-std/manifest/schema/dsh-plugin-0.15.schema.json +144 -144
- package/node_modules/@dsh-std/messages/CHANGELOG.md +8 -8
- package/node_modules/@dsh-std/messages/LICENSE +21 -21
- package/node_modules/@dsh-std/messages/README.md +5 -5
- package/node_modules/@dsh-std/messages/README.zh.md +7 -7
- package/node_modules/@dsh-std/messages/lib/index.js.map +1 -1
- package/node_modules/@dsh-std/messages/package.json +20 -20
- package/node_modules/@dsh-std/messages/schema/message-observer-envelope-0.15.schema.json +54 -54
- package/node_modules/@dsh-std/presentation/CHANGELOG.md +9 -9
- package/node_modules/@dsh-std/presentation/LICENSE +21 -21
- package/node_modules/@dsh-std/presentation/README.md +27 -27
- package/node_modules/@dsh-std/presentation/README.zh.md +29 -29
- package/node_modules/@dsh-std/presentation/lib/callback.js.map +1 -1
- package/node_modules/@dsh-std/presentation/lib/index.js.map +1 -1
- package/node_modules/@dsh-std/presentation/package.json +25 -25
- package/node_modules/@dsh-std/storage/CHANGELOG.md +8 -8
- package/node_modules/@dsh-std/storage/LICENSE +21 -21
- package/node_modules/@dsh-std/storage/README.md +5 -5
- package/node_modules/@dsh-std/storage/README.zh.md +7 -7
- package/node_modules/@dsh-std/storage/lib/index.js.map +1 -1
- package/node_modules/@dsh-std/storage/package.json +20 -20
- package/node_modules/@dsh-std/storage/schema/local-storage-0.15.schema.json +56 -56
- package/package.json +95 -5
- package/skills/pr-comments/SKILL.md +1 -1
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/CHANGELOG.md +8 -8
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/LICENSE +21 -21
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/README.md +42 -42
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/README.zh.md +42 -42
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/index.js.map +1 -1
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/memory.js.map +1 -1
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/resolve-3X6ausgz.js.map +1 -1
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/package.json +20 -20
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/CHANGELOG.md +8 -8
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/LICENSE +21 -21
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/README.md +13 -13
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/README.zh.md +13 -13
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/lib/index.js.map +1 -1
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/core/package.json +21 -21
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/CHANGELOG.md +9 -9
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/LICENSE +21 -21
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/README.md +5 -5
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/README.zh.md +5 -5
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/lib/index.js.map +1 -1
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/package.json +20 -20
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/manifest/schema/dsh-plugin-0.15.schema.json +144 -144
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/CHANGELOG.md +9 -9
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/LICENSE +21 -21
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/README.md +27 -27
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/README.zh.md +29 -29
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/callback.js.map +1 -1
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/lib/index.js.map +1 -1
- package/vendor/dsh-std/packages/command/node_modules/@dsh-std/presentation/package.json +25 -25
- package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/CHANGELOG.md +8 -8
- package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/LICENSE +21 -21
- package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/README.md +13 -13
- package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/README.zh.md +13 -13
- package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/lib/index.js.map +1 -1
- package/vendor/dsh-std/packages/connection/node_modules/@dsh-std/core/package.json +21 -21
- package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/CHANGELOG.md +8 -8
- package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/LICENSE +21 -21
- package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/README.md +13 -13
- package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/README.zh.md +13 -13
- package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/lib/index.js.map +1 -1
- package/vendor/dsh-std/packages/manifest/node_modules/@dsh-std/core/package.json +21 -21
- package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/CHANGELOG.md +8 -8
- package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/LICENSE +21 -21
- package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/README.md +13 -13
- package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/README.zh.md +13 -13
- package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/lib/index.js.map +1 -1
- package/vendor/dsh-std/packages/messages/node_modules/@dsh-std/core/package.json +21 -21
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/CHANGELOG.md +8 -8
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/LICENSE +21 -21
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/README.md +42 -42
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/README.zh.md +42 -42
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/index.js.map +1 -1
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/memory.js.map +1 -1
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/lib/resolve-3X6ausgz.js.map +1 -1
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/connection/package.json +20 -20
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/CHANGELOG.md +8 -8
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/LICENSE +21 -21
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/README.md +13 -13
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/README.zh.md +13 -13
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/lib/index.js.map +1 -1
- package/vendor/dsh-std/packages/presentation/node_modules/@dsh-std/core/package.json +21 -21
- package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/CHANGELOG.md +8 -8
- package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/LICENSE +21 -21
- package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/README.md +13 -13
- package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/README.zh.md +13 -13
- package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/lib/index.js.map +1 -1
- package/vendor/dsh-std/packages/storage/node_modules/@dsh-std/core/package.json +21 -21
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory.js","names":[],"sources":["../src/memory.ts"],"sourcesContent":["import { sameProtocol, type ApiReference } from '@dsh-std/core'\r\nimport {\r\n ConnectionInvocationError,\r\n type CapabilityCall,\r\n type CapabilityClient,\r\n type CapabilityDispatch,\r\n type CapabilityImplementation,\r\n type ConnectionEndpoint,\r\n type StandardConnection,\r\n} from './connection.js'\r\nimport {\r\n validateEndpointOffer,\r\n type CapabilityBinding,\r\n type ConnectionPlan,\r\n type EndpointOffer,\r\n type ResolveConnectionOptions,\r\n} from './model.js'\r\nimport { resolveConnection } from './resolve.js'\r\n\r\nexport class MemoryConnectionEndpoint implements ConnectionEndpoint {\r\n private currentOffer: EndpointOffer\r\n private readonly implementations: CapabilityImplementation[] = []\r\n private readonly offerListeners = new Set<(offer: EndpointOffer) => void>()\r\n\r\n constructor(offer: EndpointOffer) {\r\n validateEndpointOffer(offer)\r\n this.currentOffer = offer\r\n }\r\n\r\n get offer(): EndpointOffer { return this.currentOffer }\r\n\r\n replaceOffer(offer: EndpointOffer): void {\r\n validateEndpointOffer(offer)\r\n if (offer.endpoint.instanceId !== this.currentOffer.endpoint.instanceId) throw new TypeError('replacement offer belongs to another endpoint')\r\n if (offer.revision <= this.currentOffer.revision) throw new TypeError('replacement offer must increase revision')\r\n this.currentOffer = offer\r\n for (const listener of this.offerListeners) listener(offer)\r\n }\r\n\r\n register(implementation: CapabilityImplementation): () => void {\r\n const declaration = this.currentOffer.declarations.find(row => row.participant.id === implementation.participantId)\r\n if (declaration === undefined || !(declaration.supports ?? []).some(row => sameProtocol(row, implementation.protocol))) {\r\n throw new TypeError('implementation is not backed by a live endpoint declaration')\r\n }\r\n if (this.implementations.some(row => row.participantId === implementation.participantId && sameProtocol(row.protocol, implementation.protocol))) {\r\n throw new TypeError('capability implementation is already registered')\r\n }\r\n const stored = Object.freeze({ ...implementation, protocol: Object.freeze({ ...implementation.protocol }) })\r\n this.implementations.push(stored)\r\n return () => {\r\n const index = this.implementations.indexOf(stored)\r\n if (index >= 0) this.implementations.splice(index, 1)\r\n }\r\n }\r\n\r\n async dispatch<TInput = unknown, TOutput = unknown, TProgress = unknown>(invocation: CapabilityDispatch<TInput, TProgress>): Promise<TOutput> {\r\n const implementation = this.implementations.find(row =>\r\n row.participantId === invocation.binding.provider.participantId\r\n && sameProtocol(row.protocol, invocation.binding.support))\r\n if (implementation === undefined) throw new ConnectionInvocationError('handler-missing', 'binding has no live implementation')\r\n return await implementation.handle(invocation.operation, invocation.input, Object.freeze({\r\n connectionId: invocation.connectionId,\r\n planRevision: invocation.planRevision,\r\n invocationId: invocation.invocationId,\r\n binding: invocation.binding,\r\n signal: invocation.signal,\r\n progress: invocation.progress,\r\n })) as TOutput\r\n }\r\n\r\n onOfferChange(listener: (offer: EndpointOffer) => void): () => void {\r\n this.offerListeners.add(listener)\r\n return () => { this.offerListeners.delete(listener) }\r\n }\r\n}\r\n\r\nexport interface MemoryConnectionPair {\r\n readonly left: StandardConnection\r\n readonly right: StandardConnection\r\n readonly plan: ConnectionPlan\r\n renegotiate(options: ResolveConnectionOptions): ConnectionPlan\r\n close(reason?: string): void\r\n}\r\n\r\nexport function createMemoryConnectionPair(\r\n left: ConnectionEndpoint, right: ConnectionEndpoint, options: ResolveConnectionOptions,\r\n): MemoryConnectionPair {\r\n return new MemoryPair(left, right, options)\r\n}\r\n\r\nclass MemoryPair implements MemoryConnectionPair {\r\n private currentPlan: ConnectionPlan\r\n private closed = false\r\n private invocationSequence = 0\r\n private readonly listeners = new Set<(plan: ConnectionPlan) => void>()\r\n private readonly active = new Map<string, (reason?: string, code?: 'cancelled' | 'connection-closed') => void>()\r\n readonly left: StandardConnection\r\n readonly right: StandardConnection\r\n\r\n constructor(\r\n private readonly leftEndpoint: ConnectionEndpoint,\r\n private readonly rightEndpoint: ConnectionEndpoint,\r\n options: ResolveConnectionOptions,\r\n ) {\r\n this.currentPlan = resolveConnection(leftEndpoint.offer, rightEndpoint.offer, options)\r\n this.left = new MemoryConnectionView(this, leftEndpoint, rightEndpoint)\r\n this.right = new MemoryConnectionView(this, rightEndpoint, leftEndpoint)\r\n }\r\n\r\n get plan(): ConnectionPlan { return this.currentPlan }\r\n\r\n renegotiate(options: ResolveConnectionOptions): ConnectionPlan {\r\n this.assertOpen()\r\n if (options.connectionId !== this.currentPlan.connectionId || options.revision <= this.currentPlan.revision) {\r\n throw new TypeError('renegotiation must retain connectionId and increase revision')\r\n }\r\n this.currentPlan = resolveConnection(this.leftEndpoint.offer, this.rightEndpoint.offer, options)\r\n for (const listener of this.listeners) listener(this.currentPlan)\r\n return this.currentPlan\r\n }\r\n\r\n subscribe(listener: (plan: ConnectionPlan) => void): () => void {\r\n this.listeners.add(listener)\r\n return () => { this.listeners.delete(listener) }\r\n }\r\n\r\n binding(local: ConnectionEndpoint, participantId: string, reference: ApiReference): CapabilityBinding | undefined {\r\n if (this.closed) return undefined\r\n return this.currentPlan.bindings.find(binding =>\r\n binding.consumer.endpoint.instanceId === local.offer.endpoint.instanceId\r\n && binding.consumer.participantId === participantId\r\n && sameProtocol(binding.requirement, reference))\r\n }\r\n\r\n invoke<TInput, TOutput, TProgress>(\r\n local: ConnectionEndpoint,\r\n participantId: string,\r\n reference: ApiReference,\r\n operation: string,\r\n input: TInput,\r\n signal?: AbortSignal,\r\n ): CapabilityCall<TOutput, TProgress> {\r\n this.assertOpen()\r\n signal?.throwIfAborted()\r\n const binding = this.binding(local, participantId, reference)\r\n if (binding === undefined) throw new ConnectionInvocationError('capability-unbound', `participant ${JSON.stringify(participantId)} has no binding`)\r\n const target = binding.provider.endpoint.instanceId === this.leftEndpoint.offer.endpoint.instanceId\r\n ? this.leftEndpoint\r\n : binding.provider.endpoint.instanceId === this.rightEndpoint.offer.endpoint.instanceId ? this.rightEndpoint : undefined\r\n if (target === undefined) throw new ConnectionInvocationError('handler-missing', 'binding provider endpoint is unavailable')\r\n const invocationId = `${local.offer.endpoint.instanceId}:${String(++this.invocationSequence)}`\r\n const controller = new AbortController()\r\n const progress = new AsyncProgress<TProgress>()\r\n let settled = false\r\n let resolveResult!: (value: TOutput | PromiseLike<TOutput>) => void\r\n let rejectResult!: (reason?: unknown) => void\r\n const result = new Promise<TOutput>((resolve, reject) => { resolveResult = resolve; rejectResult = reject })\r\n const finish = () => { settled = true; this.active.delete(invocationId); progress.close() }\r\n const cancel = (reason = 'capability invocation cancelled', code: 'cancelled' | 'connection-closed' = 'cancelled') => {\r\n if (settled) return\r\n controller.abort(reason)\r\n finish()\r\n rejectResult(new ConnectionInvocationError(code, reason))\r\n }\r\n this.active.set(invocationId, cancel)\r\n if (signal !== undefined) signal.addEventListener('abort', () => cancel(abortMessage(signal)), { once: true })\r\n queueMicrotask(() => {\r\n if (settled) return\r\n Promise.resolve(target.dispatch<TInput, TOutput, TProgress>({\r\n connectionId: this.currentPlan.connectionId,\r\n planRevision: binding.planRevision,\r\n invocationId,\r\n binding,\r\n operation,\r\n input,\r\n signal: controller.signal,\r\n progress: value => { if (!settled) progress.push(value) },\r\n })).then(value => { if (!settled) { finish(); resolveResult(value) } }, error => {\r\n if (!settled) { finish(); rejectResult(error) }\r\n })\r\n })\r\n return Object.freeze({ invocationId, result, progress, cancel })\r\n }\r\n\r\n close(reason = 'connection closed'): void {\r\n if (this.closed) return\r\n this.closed = true\r\n for (const cancel of this.active.values()) cancel(reason, 'connection-closed')\r\n this.active.clear()\r\n this.listeners.clear()\r\n }\r\n\r\n private assertOpen(): void {\r\n if (this.closed) throw new ConnectionInvocationError('connection-closed', 'connection is closed')\r\n }\r\n\r\n}\r\n\r\nclass MemoryConnectionView implements StandardConnection {\r\n constructor(\r\n private readonly pair: MemoryPair,\r\n private readonly localEndpoint: ConnectionEndpoint,\r\n private readonly remoteEndpoint: ConnectionEndpoint,\r\n ) {}\r\n\r\n get id(): string { return this.pair.plan.connectionId }\r\n get local() { return this.localEndpoint.offer.endpoint }\r\n get remote() { return this.remoteEndpoint.offer.endpoint }\r\n get plan() { return this.pair.plan }\r\n\r\n client(participantId: string): CapabilityClient {\r\n nonEmpty(participantId, 'participantId')\r\n return Object.freeze({\r\n participantId,\r\n binding: (reference: ApiReference) => this.pair.binding(this.localEndpoint, participantId, reference),\r\n invoke: <TInput, TOutput, TProgress>(\r\n reference: ApiReference, operation: string, input: TInput, options?: { readonly signal?: AbortSignal },\r\n ) => this.pair.invoke<TInput, TOutput, TProgress>(this.localEndpoint, participantId, reference, operation, input, options?.signal),\r\n })\r\n }\r\n\r\n onPlanChange(listener: (plan: ConnectionPlan) => void): () => void { return this.pair.subscribe(listener) }\r\n close(reason?: string): void { this.pair.close(reason) }\r\n}\r\n\r\nclass AsyncProgress<T> implements AsyncIterableIterator<T> {\r\n private readonly values: T[] = []\r\n private readonly waiters: Array<(result: IteratorResult<T>) => void> = []\r\n private done = false\r\n push(value: T): void {\r\n if (this.done) return\r\n const waiter = this.waiters.shift()\r\n if (waiter === undefined) this.values.push(value)\r\n else waiter({ done: false, value })\r\n }\r\n close(): void {\r\n if (this.done) return\r\n this.done = true\r\n for (const waiter of this.waiters.splice(0)) waiter({ done: true, value: undefined })\r\n }\r\n next(): Promise<IteratorResult<T>> {\r\n if (this.values.length > 0) return Promise.resolve({ done: false, value: this.values.shift() as T })\r\n if (this.done) return Promise.resolve({ done: true, value: undefined })\r\n return new Promise(resolve => { this.waiters.push(resolve) })\r\n }\r\n return(): Promise<IteratorResult<T>> { this.close(); return Promise.resolve({ done: true, value: undefined }) }\r\n [Symbol.asyncIterator](): AsyncIterableIterator<T> { return this }\r\n}\r\n\r\nfunction abortMessage(signal: AbortSignal): string {\r\n return signal.reason instanceof Error ? signal.reason.message : typeof signal.reason === 'string' ? signal.reason : 'capability invocation cancelled'\r\n}\r\n\r\nfunction nonEmpty(value: string, label: string): void {\r\n if (typeof value !== 'string' || value.trim() === '') throw new TypeError(`${label} must be non-empty`)\r\n}\r\n"],"mappings":";;;AAmBA,IAAa,2BAAb,MAAoE;CAClE;CACA,kBAA+D,CAAC;CAChE,iCAAkC,IAAI,IAAoC;CAE1E,YAAY,OAAsB;EAChC,sBAAsB,KAAK;EAC3B,KAAK,eAAe;CACtB;CAEA,IAAI,QAAuB;EAAE,OAAO,KAAK;CAAa;CAEtD,aAAa,OAA4B;EACvC,sBAAsB,KAAK;EAC3B,IAAI,MAAM,SAAS,eAAe,KAAK,aAAa,SAAS,YAAY,MAAM,IAAI,UAAU,+CAA+C;EAC5I,IAAI,MAAM,YAAY,KAAK,aAAa,UAAU,MAAM,IAAI,UAAU,0CAA0C;EAChH,KAAK,eAAe;EACpB,KAAK,MAAM,YAAY,KAAK,gBAAgB,SAAS,KAAK;CAC5D;CAEA,SAAS,gBAAsD;EAC7D,MAAM,cAAc,KAAK,aAAa,aAAa,MAAK,QAAO,IAAI,YAAY,OAAO,eAAe,aAAa;EAClH,IAAI,gBAAgB,KAAA,KAAa,EAAE,YAAY,YAAY,CAAC,EAAA,CAAG,MAAK,QAAO,aAAa,KAAK,eAAe,QAAQ,CAAC,GACnH,MAAM,IAAI,UAAU,6DAA6D;EAEnF,IAAI,KAAK,gBAAgB,MAAK,QAAO,IAAI,kBAAkB,eAAe,iBAAiB,aAAa,IAAI,UAAU,eAAe,QAAQ,CAAC,GAC5I,MAAM,IAAI,UAAU,iDAAiD;EAEvE,MAAM,SAAS,OAAO,OAAO;GAAE,GAAG;GAAgB,UAAU,OAAO,OAAO,EAAE,GAAG,eAAe,SAAS,CAAC;EAAE,CAAC;EAC3G,KAAK,gBAAgB,KAAK,MAAM;EAChC,aAAa;GACX,MAAM,QAAQ,KAAK,gBAAgB,QAAQ,MAAM;GACjD,IAAI,SAAS,GAAG,KAAK,gBAAgB,OAAO,OAAO,CAAC;EACtD;CACF;CA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,YAAW;GAAE,KAAK,QAAQ,KAAK,OAAO;EAAE,CAAC;CAC9D;CACA,SAAqC;EAAE,KAAK,MAAM;EAAG,OAAO,QAAQ,QAAQ;GAAE,MAAM;GAAM,OAAO,KAAA;EAAU,CAAC;CAAE;CAC9G,CAAC,OAAO,iBAA2C;EAAE,OAAO;CAAK;AACnE;AAEA,SAAS,aAAa,QAA6B;CACjD,OAAO,OAAO,kBAAkB,QAAQ,OAAO,OAAO,UAAU,OAAO,OAAO,WAAW,WAAW,OAAO,SAAS;AACtH;AAEA,SAAS,SAAS,OAAe,OAAqB;CACpD,IAAI,OAAO,UAAU,YAAY,MAAM,KAAK,MAAM,IAAI,MAAM,IAAI,UAAU,GAAG,MAAM,mBAAmB;AACxG"}
|
|
1
|
+
{"version":3,"file":"memory.js","names":[],"sources":["../src/memory.ts"],"sourcesContent":["import { sameProtocol, type ApiReference } from '@dsh-std/core'\nimport {\n ConnectionInvocationError,\n type CapabilityCall,\n type CapabilityClient,\n type CapabilityDispatch,\n type CapabilityImplementation,\n type ConnectionEndpoint,\n type StandardConnection,\n} from './connection.js'\nimport {\n validateEndpointOffer,\n type CapabilityBinding,\n type ConnectionPlan,\n type EndpointOffer,\n type ResolveConnectionOptions,\n} from './model.js'\nimport { resolveConnection } from './resolve.js'\n\nexport class MemoryConnectionEndpoint implements ConnectionEndpoint {\n private currentOffer: EndpointOffer\n private readonly implementations: CapabilityImplementation[] = []\n private readonly offerListeners = new Set<(offer: EndpointOffer) => void>()\n\n constructor(offer: EndpointOffer) {\n validateEndpointOffer(offer)\n this.currentOffer = offer\n }\n\n get offer(): EndpointOffer { return this.currentOffer }\n\n replaceOffer(offer: EndpointOffer): void {\n validateEndpointOffer(offer)\n if (offer.endpoint.instanceId !== this.currentOffer.endpoint.instanceId) throw new TypeError('replacement offer belongs to another endpoint')\n if (offer.revision <= this.currentOffer.revision) throw new TypeError('replacement offer must increase revision')\n this.currentOffer = offer\n for (const listener of this.offerListeners) listener(offer)\n }\n\n register(implementation: CapabilityImplementation): () => void {\n const declaration = this.currentOffer.declarations.find(row => row.participant.id === implementation.participantId)\n if (declaration === undefined || !(declaration.supports ?? []).some(row => sameProtocol(row, implementation.protocol))) {\n throw new TypeError('implementation is not backed by a live endpoint declaration')\n }\n if (this.implementations.some(row => row.participantId === implementation.participantId && sameProtocol(row.protocol, implementation.protocol))) {\n throw new TypeError('capability implementation is already registered')\n }\n const stored = Object.freeze({ ...implementation, protocol: Object.freeze({ ...implementation.protocol }) })\n this.implementations.push(stored)\n return () => {\n const index = this.implementations.indexOf(stored)\n if (index >= 0) this.implementations.splice(index, 1)\n }\n }\n\n async dispatch<TInput = unknown, TOutput = unknown, TProgress = unknown>(invocation: CapabilityDispatch<TInput, TProgress>): Promise<TOutput> {\n const implementation = this.implementations.find(row =>\n row.participantId === invocation.binding.provider.participantId\n && sameProtocol(row.protocol, invocation.binding.support))\n if (implementation === undefined) throw new ConnectionInvocationError('handler-missing', 'binding has no live implementation')\n return await implementation.handle(invocation.operation, invocation.input, Object.freeze({\n connectionId: invocation.connectionId,\n planRevision: invocation.planRevision,\n invocationId: invocation.invocationId,\n binding: invocation.binding,\n signal: invocation.signal,\n progress: invocation.progress,\n })) as TOutput\n }\n\n onOfferChange(listener: (offer: EndpointOffer) => void): () => void {\n this.offerListeners.add(listener)\n return () => { this.offerListeners.delete(listener) }\n }\n}\n\nexport interface MemoryConnectionPair {\n readonly left: StandardConnection\n readonly right: StandardConnection\n readonly plan: ConnectionPlan\n renegotiate(options: ResolveConnectionOptions): ConnectionPlan\n close(reason?: string): void\n}\n\nexport function createMemoryConnectionPair(\n left: ConnectionEndpoint, right: ConnectionEndpoint, options: ResolveConnectionOptions,\n): MemoryConnectionPair {\n return new MemoryPair(left, right, options)\n}\n\nclass MemoryPair implements MemoryConnectionPair {\n private currentPlan: ConnectionPlan\n private closed = false\n private invocationSequence = 0\n private readonly listeners = new Set<(plan: ConnectionPlan) => void>()\n private readonly active = new Map<string, (reason?: string, code?: 'cancelled' | 'connection-closed') => void>()\n readonly left: StandardConnection\n readonly right: StandardConnection\n\n constructor(\n private readonly leftEndpoint: ConnectionEndpoint,\n private readonly rightEndpoint: ConnectionEndpoint,\n options: ResolveConnectionOptions,\n ) {\n this.currentPlan = resolveConnection(leftEndpoint.offer, rightEndpoint.offer, options)\n this.left = new MemoryConnectionView(this, leftEndpoint, rightEndpoint)\n this.right = new MemoryConnectionView(this, rightEndpoint, leftEndpoint)\n }\n\n get plan(): ConnectionPlan { return this.currentPlan }\n\n renegotiate(options: ResolveConnectionOptions): ConnectionPlan {\n this.assertOpen()\n if (options.connectionId !== this.currentPlan.connectionId || options.revision <= this.currentPlan.revision) {\n throw new TypeError('renegotiation must retain connectionId and increase revision')\n }\n this.currentPlan = resolveConnection(this.leftEndpoint.offer, this.rightEndpoint.offer, options)\n for (const listener of this.listeners) listener(this.currentPlan)\n return this.currentPlan\n }\n\n subscribe(listener: (plan: ConnectionPlan) => void): () => void {\n this.listeners.add(listener)\n return () => { this.listeners.delete(listener) }\n }\n\n binding(local: ConnectionEndpoint, participantId: string, reference: ApiReference): CapabilityBinding | undefined {\n if (this.closed) return undefined\n return this.currentPlan.bindings.find(binding =>\n binding.consumer.endpoint.instanceId === local.offer.endpoint.instanceId\n && binding.consumer.participantId === participantId\n && sameProtocol(binding.requirement, reference))\n }\n\n invoke<TInput, TOutput, TProgress>(\n local: ConnectionEndpoint,\n participantId: string,\n reference: ApiReference,\n operation: string,\n input: TInput,\n signal?: AbortSignal,\n ): CapabilityCall<TOutput, TProgress> {\n this.assertOpen()\n signal?.throwIfAborted()\n const binding = this.binding(local, participantId, reference)\n if (binding === undefined) throw new ConnectionInvocationError('capability-unbound', `participant ${JSON.stringify(participantId)} has no binding`)\n const target = binding.provider.endpoint.instanceId === this.leftEndpoint.offer.endpoint.instanceId\n ? this.leftEndpoint\n : binding.provider.endpoint.instanceId === this.rightEndpoint.offer.endpoint.instanceId ? this.rightEndpoint : undefined\n if (target === undefined) throw new ConnectionInvocationError('handler-missing', 'binding provider endpoint is unavailable')\n const invocationId = `${local.offer.endpoint.instanceId}:${String(++this.invocationSequence)}`\n const controller = new AbortController()\n const progress = new AsyncProgress<TProgress>()\n let settled = false\n let resolveResult!: (value: TOutput | PromiseLike<TOutput>) => void\n let rejectResult!: (reason?: unknown) => void\n const result = new Promise<TOutput>((resolve, reject) => { resolveResult = resolve; rejectResult = reject })\n const finish = () => { settled = true; this.active.delete(invocationId); progress.close() }\n const cancel = (reason = 'capability invocation cancelled', code: 'cancelled' | 'connection-closed' = 'cancelled') => {\n if (settled) return\n controller.abort(reason)\n finish()\n rejectResult(new ConnectionInvocationError(code, reason))\n }\n this.active.set(invocationId, cancel)\n if (signal !== undefined) signal.addEventListener('abort', () => cancel(abortMessage(signal)), { once: true })\n queueMicrotask(() => {\n if (settled) return\n Promise.resolve(target.dispatch<TInput, TOutput, TProgress>({\n connectionId: this.currentPlan.connectionId,\n planRevision: binding.planRevision,\n invocationId,\n binding,\n operation,\n input,\n signal: controller.signal,\n progress: value => { if (!settled) progress.push(value) },\n })).then(value => { if (!settled) { finish(); resolveResult(value) } }, error => {\n if (!settled) { finish(); rejectResult(error) }\n })\n })\n return Object.freeze({ invocationId, result, progress, cancel })\n }\n\n close(reason = 'connection closed'): void {\n if (this.closed) return\n this.closed = true\n for (const cancel of this.active.values()) cancel(reason, 'connection-closed')\n this.active.clear()\n this.listeners.clear()\n }\n\n private assertOpen(): void {\n if (this.closed) throw new ConnectionInvocationError('connection-closed', 'connection is closed')\n }\n\n}\n\nclass MemoryConnectionView implements StandardConnection {\n constructor(\n private readonly pair: MemoryPair,\n private readonly localEndpoint: ConnectionEndpoint,\n private readonly remoteEndpoint: ConnectionEndpoint,\n ) {}\n\n get id(): string { return this.pair.plan.connectionId }\n get local() { return this.localEndpoint.offer.endpoint }\n get remote() { return this.remoteEndpoint.offer.endpoint }\n get plan() { return this.pair.plan }\n\n client(participantId: string): CapabilityClient {\n nonEmpty(participantId, 'participantId')\n return Object.freeze({\n participantId,\n binding: (reference: ApiReference) => this.pair.binding(this.localEndpoint, participantId, reference),\n invoke: <TInput, TOutput, TProgress>(\n reference: ApiReference, operation: string, input: TInput, options?: { readonly signal?: AbortSignal },\n ) => this.pair.invoke<TInput, TOutput, TProgress>(this.localEndpoint, participantId, reference, operation, input, options?.signal),\n })\n }\n\n onPlanChange(listener: (plan: ConnectionPlan) => void): () => void { return this.pair.subscribe(listener) }\n close(reason?: string): void { this.pair.close(reason) }\n}\n\nclass AsyncProgress<T> implements AsyncIterableIterator<T> {\n private readonly values: T[] = []\n private readonly waiters: Array<(result: IteratorResult<T>) => void> = []\n private done = false\n push(value: T): void {\n if (this.done) return\n const waiter = this.waiters.shift()\n if (waiter === undefined) this.values.push(value)\n else waiter({ done: false, value })\n }\n close(): void {\n if (this.done) return\n this.done = true\n for (const waiter of this.waiters.splice(0)) waiter({ done: true, value: undefined })\n }\n next(): Promise<IteratorResult<T>> {\n if (this.values.length > 0) return Promise.resolve({ done: false, value: this.values.shift() as T })\n if (this.done) return Promise.resolve({ done: true, value: undefined })\n return new Promise(resolve => { this.waiters.push(resolve) })\n }\n return(): Promise<IteratorResult<T>> { this.close(); return Promise.resolve({ done: true, value: undefined }) }\n [Symbol.asyncIterator](): AsyncIterableIterator<T> { return this }\n}\n\nfunction abortMessage(signal: AbortSignal): string {\n return signal.reason instanceof Error ? signal.reason.message : typeof signal.reason === 'string' ? signal.reason : 'capability invocation cancelled'\n}\n\nfunction nonEmpty(value: string, label: string): void {\n if (typeof value !== 'string' || value.trim() === '') throw new TypeError(`${label} must be non-empty`)\n}\n"],"mappings":";;;AAmBA,IAAa,2BAAb,MAAoE;CAClE;CACA,kBAA+D,CAAC;CAChE,iCAAkC,IAAI,IAAoC;CAE1E,YAAY,OAAsB;EAChC,sBAAsB,KAAK;EAC3B,KAAK,eAAe;CACtB;CAEA,IAAI,QAAuB;EAAE,OAAO,KAAK;CAAa;CAEtD,aAAa,OAA4B;EACvC,sBAAsB,KAAK;EAC3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AAe,OAAqB;CACpD,IAAI,OAAO,UAAU,YAAY,MAAM,KAAK,MAAM,IAAI,MAAM,IAAI,UAAU,GAAG,MAAM,mBAAmB;AACxG"}
|
package/vendor/dsh-std/packages/command/node_modules/@dsh-std/connection/lib/resolve-3X6ausgz.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-3X6ausgz.js","names":[],"sources":["../src/model.ts","../src/connection.ts","../src/rpc.ts","../src/resolve.ts"],"sourcesContent":["import type {\r\n NegotiatedProtocol,\r\n ProtocolDeclaration,\r\n ProtocolRequirement,\r\n ProtocolSupport,\r\n} from '@dsh-std/core'\r\nimport type { ProtocolCatalog } from '@dsh-std/core'\r\nimport { defineProtocolDeclaration, validateProtocolDeclaration } from '@dsh-std/core'\r\n\r\nexport const CONNECTION_API_VERSION = 'connection.dsh/v1alpha1'\r\n\r\nexport interface EndpointIdentity {\r\n readonly id: string\r\n readonly instanceId: string\r\n}\r\n\r\nexport interface EndpointOffer {\r\n readonly apiVersion: typeof CONNECTION_API_VERSION\r\n readonly kind: 'ConnectionOffer'\r\n readonly endpoint: EndpointIdentity\r\n readonly revision: number\r\n readonly declarations: readonly ProtocolDeclaration[]\r\n}\r\n\r\nexport interface ConnectionEndpointReference extends EndpointIdentity {}\r\n\r\nexport interface CapabilityParticipant {\r\n readonly endpoint: ConnectionEndpointReference\r\n readonly participantId: string\r\n}\r\n\r\nexport interface CapabilityBinding {\r\n readonly bindingId: string\r\n readonly agreementId: string\r\n readonly planRevision: number\r\n readonly consumer: CapabilityParticipant\r\n readonly provider: CapabilityParticipant\r\n readonly requirement: ProtocolRequirement\r\n readonly support: ProtocolSupport\r\n}\r\n\r\nexport interface ConnectionIssue {\r\n readonly severity: 'error' | 'warning'\r\n readonly code: string\r\n readonly participant?: CapabilityParticipant\r\n readonly path?: string\r\n readonly message: string\r\n}\r\n\r\nexport interface ConnectionPlan {\r\n readonly apiVersion: typeof CONNECTION_API_VERSION\r\n readonly kind: 'ConnectionAgreement'\r\n readonly connectionId: string\r\n readonly revision: number\r\n readonly digest: string\r\n readonly offers: readonly {\r\n readonly endpoint: ConnectionEndpointReference\r\n readonly revision: number\r\n }[]\r\n readonly compatible: boolean\r\n readonly protocols: readonly NegotiatedProtocol[]\r\n readonly bindings: readonly CapabilityBinding[]\r\n readonly issues: readonly ConnectionIssue[]\r\n}\r\n\r\nexport interface ResolveConnectionOptions {\r\n readonly connectionId: string\r\n readonly revision: number\r\n readonly protocols: ProtocolCatalog\r\n readonly policy?: unknown\r\n}\r\n\r\n/** Policy envelope supplied to definitions while evaluating a pair of endpoint offers. */\r\nexport interface ConnectionNegotiationPolicy {\r\n readonly endpointByParticipant: Readonly<Record<string, string>>\r\n readonly protocol?: unknown\r\n}\r\n\r\nexport function createEndpointOffer(\r\n endpoint: EndpointIdentity,\r\n revision: number,\r\n declarations: readonly ProtocolDeclaration[],\r\n): EndpointOffer {\r\n validateEndpoint(endpoint)\r\n validateOfferRevision(revision)\r\n const seen = new Set<string>()\r\n const normalized = declarations.map(declaration => defineProtocolDeclaration(declaration))\r\n for (const declaration of normalized) {\r\n if (seen.has(declaration.participant.id)) throw new TypeError(`duplicate endpoint participant ${JSON.stringify(declaration.participant.id)}`)\r\n seen.add(declaration.participant.id)\r\n }\r\n return Object.freeze({\r\n apiVersion: CONNECTION_API_VERSION,\r\n kind: 'ConnectionOffer',\r\n endpoint: freezeEndpoint(endpoint),\r\n revision,\r\n declarations: Object.freeze(normalized),\r\n })\r\n}\r\n\r\nexport function validateEndpointOffer(offer: EndpointOffer): void {\r\n if (offer.apiVersion !== CONNECTION_API_VERSION || offer.kind !== 'ConnectionOffer') throw new TypeError('endpoint offer version or kind is unsupported')\r\n validateEndpoint(offer.endpoint)\r\n validateOfferRevision(offer.revision)\r\n if (!Array.isArray(offer.declarations)) throw new TypeError('endpoint offer declarations must be an array')\r\n const seen = new Set<string>()\r\n for (const declaration of offer.declarations) {\r\n validateProtocolDeclaration(declaration)\r\n if (seen.has(declaration.participant.id)) throw new TypeError(`duplicate endpoint participant ${JSON.stringify(declaration.participant.id)}`)\r\n seen.add(declaration.participant.id)\r\n }\r\n}\r\n\r\nexport function freezeEndpoint(endpoint: EndpointIdentity): ConnectionEndpointReference {\r\n return Object.freeze({ id: endpoint.id, instanceId: endpoint.instanceId })\r\n}\r\n\r\nexport function validatePlanCoordinates(connectionId: string, revision: number): void {\r\n nonEmpty(connectionId, 'connectionId')\r\n if (!Number.isSafeInteger(revision) || revision < 1) throw new TypeError('connection revision must be a positive safe integer')\r\n}\r\n\r\nfunction validateEndpoint(endpoint: EndpointIdentity): void {\r\n nonEmpty(endpoint.id, 'endpoint.id')\r\n nonEmpty(endpoint.instanceId, 'endpoint.instanceId')\r\n}\r\n\r\nfunction validateOfferRevision(revision: number): void {\r\n if (!Number.isSafeInteger(revision) || revision < 0) throw new TypeError('offer revision must be a non-negative safe integer')\r\n}\r\n\r\nfunction nonEmpty(value: string, label: string): void {\r\n if (typeof value !== 'string' || value.trim() === '') throw new TypeError(`${label} must be a non-empty string`)\r\n}\r\n","import type { ApiReference, ProtocolSupport } from '@dsh-std/core'\r\nimport type { CapabilityBinding, ConnectionEndpointReference, ConnectionPlan, EndpointOffer } from './model.js'\r\n\r\nexport interface CapabilityHandlerContext<TProgress = unknown> {\r\n readonly connectionId: string\r\n readonly planRevision: number\r\n readonly invocationId: string\r\n readonly binding: CapabilityBinding\r\n readonly signal: AbortSignal\r\n progress(value: TProgress): void\r\n}\r\n\r\nexport type CapabilityHandler<TInput = unknown, TOutput = unknown, TProgress = unknown> = (\r\n operation: string, input: TInput, context: CapabilityHandlerContext<TProgress>,\r\n) => TOutput | Promise<TOutput>\r\n\r\nexport interface CapabilityImplementation<TInput = unknown, TOutput = unknown, TProgress = unknown> {\r\n readonly participantId: string\r\n readonly protocol: ProtocolSupport\r\n readonly handle: CapabilityHandler<TInput, TOutput, TProgress>\r\n}\r\n\r\nexport interface CapabilityDispatch<TInput = unknown, TProgress = unknown> {\r\n readonly connectionId: string\r\n readonly planRevision: number\r\n readonly invocationId: string\r\n readonly binding: CapabilityBinding\r\n readonly operation: string\r\n readonly input: TInput\r\n readonly signal: AbortSignal\r\n progress(value: TProgress): void\r\n}\r\n\r\nexport interface ConnectionEndpoint {\r\n readonly offer: EndpointOffer\r\n dispatch<TInput = unknown, TOutput = unknown, TProgress = unknown>(invocation: CapabilityDispatch<TInput, TProgress>): Promise<TOutput>\r\n onOfferChange(listener: (offer: EndpointOffer) => void): () => void\r\n}\r\n\r\nexport interface CapabilityCall<TOutput = unknown, TProgress = unknown> {\r\n readonly invocationId: string\r\n readonly result: Promise<TOutput>\r\n readonly progress: AsyncIterable<TProgress>\r\n cancel(reason?: string): void\r\n}\r\n\r\nexport interface CapabilityClient {\r\n readonly participantId: string\r\n binding(reference: ApiReference): CapabilityBinding | undefined\r\n invoke<TInput = unknown, TOutput = unknown, TProgress = unknown>(\r\n reference: ApiReference,\r\n operation: string,\r\n input: TInput,\r\n options?: { readonly signal?: AbortSignal },\r\n ): CapabilityCall<TOutput, TProgress>\r\n}\r\n\r\nexport interface StandardConnection {\r\n readonly id: string\r\n readonly local: ConnectionEndpointReference\r\n readonly remote: ConnectionEndpointReference\r\n readonly plan: ConnectionPlan\r\n client(participantId: string): CapabilityClient\r\n onPlanChange(listener: (plan: ConnectionPlan) => void): () => void\r\n close(reason?: string): void | Promise<void>\r\n}\r\n\r\nexport class ConnectionInvocationError extends Error {\r\n constructor(\r\n readonly code: 'connection-closed' | 'capability-unbound' | 'handler-missing' | 'cancelled' | 'handler-failed',\r\n message: string,\r\n options?: ErrorOptions,\r\n ) {\r\n super(message, options)\r\n this.name = 'ConnectionInvocationError'\r\n }\r\n}\r\n","import type {\r\n ProtocolDefinition,\r\n ProtocolIssue,\r\n ProtocolRequirement,\r\n ProtocolSupport,\r\n} from '@dsh-std/core'\r\nimport type { ConnectionNegotiationPolicy } from './model.js'\r\n\r\nexport interface CapabilityBindingDraft {\r\n readonly consumer: string\r\n readonly provider: string\r\n readonly requirement: ProtocolRequirement\r\n readonly support: ProtocolSupport\r\n}\r\n\r\nexport interface CapabilityAgreement {\r\n readonly kind: 'CapabilityBindings'\r\n readonly bindings: readonly CapabilityBindingDraft[]\r\n}\r\n\r\nexport interface CapabilityProtocolOptions {\r\n readonly apiVersion: string\r\n readonly kind: string\r\n readonly accepts?: readonly string[]\r\n readonly multipleProviders?: boolean\r\n validateRequirement?(spec: unknown): unknown\r\n validateSupport?(spec: unknown): unknown\r\n}\r\n\r\n/** Reusable RPC-shaped protocol definition. Domain packages opt into these semantics explicitly. */\r\nexport function defineCapabilityProtocol(options: CapabilityProtocolOptions): ProtocolDefinition {\r\n const definition: ProtocolDefinition = {\r\n apiVersion: options.apiVersion,\r\n kind: options.kind,\r\n ...(options.accepts === undefined ? {} : { accepts: Object.freeze([...options.accepts]) }),\r\n validateRequirement: options.validateRequirement ?? ((value: unknown) => value),\r\n validateSupport: options.validateSupport ?? ((value: unknown) => value),\r\n negotiate(input) {\r\n const issues: ProtocolIssue[] = []\r\n const bindings: CapabilityBindingDraft[] = []\r\n const connectionPolicy = isConnectionPolicy(input.policy) ? input.policy : undefined\r\n for (const row of input.requirements) {\r\n const consumerEndpoint = connectionPolicy?.endpointByParticipant[row.participant]\r\n const providers = input.supports.filter(candidate =>\r\n candidate.participant !== row.participant\r\n && (consumerEndpoint === undefined\r\n || connectionPolicy?.endpointByParticipant[candidate.participant] !== consumerEndpoint),\r\n )\r\n if (providers.length === 0) {\r\n issues.push(Object.freeze({\r\n code: row.requirement.optional === true ? 'optional-support-missing' : 'required-support-missing',\r\n severity: row.requirement.optional === true ? 'warning' : 'error',\r\n participant: row.participant,\r\n message: `no participant supports ${row.requirement.apiVersion} ${row.requirement.kind}`,\r\n }))\r\n continue\r\n }\r\n if (providers.length > 1 && options.multipleProviders !== true) {\r\n issues.push(Object.freeze({\r\n code: 'support-ambiguous', severity: 'error', participant: row.participant,\r\n message: `multiple participants support ${row.requirement.apiVersion} ${row.requirement.kind}`,\r\n }))\r\n continue\r\n }\r\n for (const provider of options.multipleProviders === true ? providers : providers.slice(0, 1)) {\r\n bindings.push(Object.freeze({\r\n consumer: row.participant,\r\n provider: provider.participant,\r\n requirement: row.requirement,\r\n support: provider.support,\r\n }))\r\n }\r\n }\r\n return {\r\n agreement: Object.freeze({ kind: 'CapabilityBindings' as const, bindings: Object.freeze(bindings) }),\r\n issues: Object.freeze(issues),\r\n }\r\n },\r\n }\r\n return Object.freeze(definition)\r\n}\r\n\r\nfunction isConnectionPolicy(value: unknown): value is ConnectionNegotiationPolicy {\r\n return typeof value === 'object' && value !== null\r\n && typeof (value as { endpointByParticipant?: unknown }).endpointByParticipant === 'object'\r\n && (value as { endpointByParticipant?: unknown }).endpointByParticipant !== null\r\n}\r\n\r\nexport function isCapabilityAgreement(value: unknown): value is CapabilityAgreement {\r\n return typeof value === 'object' && value !== null\r\n && (value as { kind?: unknown }).kind === 'CapabilityBindings'\r\n && Array.isArray((value as { bindings?: unknown }).bindings)\r\n}\r\n","import type { ProtocolIssue } from '@dsh-std/core'\r\nimport {\r\n CONNECTION_API_VERSION,\r\n freezeEndpoint,\r\n validateEndpointOffer,\r\n validatePlanCoordinates,\r\n type CapabilityBinding,\r\n type CapabilityParticipant,\r\n type ConnectionIssue,\r\n type ConnectionPlan,\r\n type ConnectionNegotiationPolicy,\r\n type EndpointOffer,\r\n type ResolveConnectionOptions,\r\n} from './model.js'\r\nimport { isCapabilityAgreement } from './rpc.js'\r\n\r\nexport function resolveConnection(left: EndpointOffer, right: EndpointOffer, options: ResolveConnectionOptions): ConnectionPlan {\r\n validateEndpointOffer(left)\r\n validateEndpointOffer(right)\r\n validatePlanCoordinates(options.connectionId, options.revision)\r\n if (left.endpoint.instanceId === right.endpoint.instanceId) throw new TypeError('connection endpoints must have distinct instanceId values')\r\n\r\n const owner = participantOwners(left, right)\r\n const endpointByParticipant = Object.freeze(Object.fromEntries(\r\n [...owner.entries()].map(([participant, row]) => [participant, row.endpoint.instanceId]),\r\n ))\r\n const policy: ConnectionNegotiationPolicy = Object.freeze({\r\n endpointByParticipant,\r\n ...(options.policy === undefined ? {} : { protocol: options.policy }),\r\n })\r\n const report = options.protocols.negotiate([...left.declarations, ...right.declarations], policy)\r\n const bindings: CapabilityBinding[] = []\r\n for (const protocol of report.protocols) {\r\n if (!isCapabilityAgreement(protocol.agreement)) continue\r\n for (const draft of protocol.agreement.bindings) {\r\n const consumer = owner.get(draft.consumer)\r\n const provider = owner.get(draft.provider)\r\n if (consumer === undefined || provider === undefined) continue\r\n bindings.push(Object.freeze({\r\n bindingId: '', agreementId: `${protocol.apiVersion}:${protocol.kind}`,\r\n planRevision: options.revision,\r\n consumer, provider,\r\n requirement: Object.freeze({ ...draft.requirement }),\r\n support: Object.freeze({ ...draft.support }),\r\n }))\r\n }\r\n }\r\n bindings.sort((a, b) => a.consumer.participantId.localeCompare(b.consumer.participantId)\r\n || a.requirement.apiVersion.localeCompare(b.requirement.apiVersion)\r\n || a.requirement.kind.localeCompare(b.requirement.kind)\r\n || a.provider.participantId.localeCompare(b.provider.participantId))\r\n const numbered = bindings.map((binding, index) => Object.freeze({ ...binding, bindingId: `binding-${String(index + 1)}` }))\r\n const issues = Object.freeze(report.issues.map(row => connectionIssue(row, owner)))\r\n const coordinates = Object.freeze([\r\n Object.freeze({ endpoint: freezeEndpoint(left.endpoint), revision: left.revision }),\r\n Object.freeze({ endpoint: freezeEndpoint(right.endpoint), revision: right.revision }),\r\n ])\r\n const digest = planDigest({ connectionId: options.connectionId, revision: options.revision, offers: coordinates, protocols: report.protocols })\r\n return Object.freeze({\r\n apiVersion: CONNECTION_API_VERSION,\r\n kind: 'ConnectionAgreement',\r\n connectionId: options.connectionId,\r\n revision: options.revision,\r\n digest,\r\n offers: coordinates,\r\n compatible: report.compatible,\r\n protocols: report.protocols,\r\n bindings: Object.freeze(numbered),\r\n issues,\r\n })\r\n}\r\n\r\nfunction planDigest(value: unknown): string {\r\n const input = canonical(value)\r\n let hash = 2166136261\r\n for (let index = 0; index < input.length; index += 1) hash = Math.imul(hash ^ input.charCodeAt(index), 16777619)\r\n return `fnv1a32:${(hash >>> 0).toString(16).padStart(8, '0')}`\r\n}\r\n\r\nfunction canonical(value: unknown): string {\r\n if (Array.isArray(value)) return `[${value.map(canonical).join(',')}]`\r\n if (typeof value === 'object' && value !== null) {\r\n return `{${Object.entries(value).sort(([a], [b]) => a.localeCompare(b)).map(([key, item]) => `${JSON.stringify(key)}:${canonical(item)}`).join(',')}}`\r\n }\r\n return JSON.stringify(value)\r\n}\r\n\r\nfunction participantOwners(left: EndpointOffer, right: EndpointOffer): Map<string, CapabilityParticipant> {\r\n const owners = new Map<string, CapabilityParticipant>()\r\n for (const offer of [left, right]) {\r\n for (const declaration of offer.declarations) {\r\n if (owners.has(declaration.participant.id)) throw new TypeError(`participant ${JSON.stringify(declaration.participant.id)} appears in both endpoint offers`)\r\n owners.set(declaration.participant.id, Object.freeze({\r\n endpoint: freezeEndpoint(offer.endpoint), participantId: declaration.participant.id,\r\n }))\r\n }\r\n }\r\n return owners\r\n}\r\n\r\nfunction connectionIssue(issue: ProtocolIssue, owners: ReadonlyMap<string, CapabilityParticipant>): ConnectionIssue {\r\n return Object.freeze({\r\n severity: issue.severity,\r\n code: issue.code,\r\n ...(issue.participant === undefined ? {} : {\r\n participant: owners.get(issue.participant) ?? Object.freeze({\r\n endpoint: Object.freeze({ id: 'unknown', instanceId: 'unknown' }), participantId: issue.participant,\r\n }),\r\n }),\r\n ...(issue.path === undefined ? {} : { path: issue.path }),\r\n message: issue.message,\r\n })\r\n}\r\n"],"mappings":";;AASA,MAAa,yBAAyB;AAqEtC,SAAgB,oBACd,UACA,UACA,cACe;CACf,iBAAiB,QAAQ;CACzB,sBAAsB,QAAQ;CAC9B,MAAM,uBAAO,IAAI,IAAY;CAC7B,MAAM,aAAa,aAAa,KAAI,gBAAe,0BAA0B,WAAW,CAAC;CACzF,KAAK,MAAM,eAAe,YAAY;EACpC,IAAI,KAAK,IAAI,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AY,EAAE,GAAG,MAAM,IAAI,UAAU,eAAe,KAAK,UAAU,YAAY,YAAY,EAAE,EAAE,iCAAiC;EAC3J,OAAO,IAAI,YAAY,YAAY,IAAI,OAAO,OAAO;GACnD,UAAU,eAAe,MAAM,QAAQ;GAAG,eAAe,YAAY,YAAY;EACnF,CAAC,CAAC;CACJ;CAEF,OAAO;AACT;AAEA,SAAS,gBAAgB,OAAsB,QAAqE;CAClH,OAAO,OAAO,OAAO;EACnB,UAAU,MAAM;EAChB,MAAM,MAAM;EACZ,GAAI,MAAM,gBAAgB,KAAA,IAAY,CAAC,IAAI,EACzC,aAAa,OAAO,IAAI,MAAM,WAAW,KAAK,OAAO,OAAO;GAC1D,UAAU,OAAO,OAAO;IAAE,IAAI;IAAW,YAAY;GAAU,CAAC;GAAG,eAAe,MAAM;EAC1F,CAAC,EACH;EACA,GAAI,MAAM,SAAS,KAAA,IAAY,CAAC,IAAI,EAAE,MAAM,MAAM,KAAK;EACvD,SAAS,MAAM;CACjB,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"resolve-3X6ausgz.js","names":[],"sources":["../src/model.ts","../src/connection.ts","../src/rpc.ts","../src/resolve.ts"],"sourcesContent":["import type {\n NegotiatedProtocol,\n ProtocolDeclaration,\n ProtocolRequirement,\n ProtocolSupport,\n} from '@dsh-std/core'\nimport type { ProtocolCatalog } from '@dsh-std/core'\nimport { defineProtocolDeclaration, validateProtocolDeclaration } from '@dsh-std/core'\n\nexport const CONNECTION_API_VERSION = 'connection.dsh/v1alpha1'\n\nexport interface EndpointIdentity {\n readonly id: string\n readonly instanceId: string\n}\n\nexport interface EndpointOffer {\n readonly apiVersion: typeof CONNECTION_API_VERSION\n readonly kind: 'ConnectionOffer'\n readonly endpoint: EndpointIdentity\n readonly revision: number\n readonly declarations: readonly ProtocolDeclaration[]\n}\n\nexport interface ConnectionEndpointReference extends EndpointIdentity {}\n\nexport interface CapabilityParticipant {\n readonly endpoint: ConnectionEndpointReference\n readonly participantId: string\n}\n\nexport interface CapabilityBinding {\n readonly bindingId: string\n readonly agreementId: string\n readonly planRevision: number\n readonly consumer: CapabilityParticipant\n readonly provider: CapabilityParticipant\n readonly requirement: ProtocolRequirement\n readonly support: ProtocolSupport\n}\n\nexport interface ConnectionIssue {\n readonly severity: 'error' | 'warning'\n readonly code: string\n readonly participant?: CapabilityParticipant\n readonly path?: string\n readonly message: string\n}\n\nexport interface ConnectionPlan {\n readonly apiVersion: typeof CONNECTION_API_VERSION\n readonly kind: 'ConnectionAgreement'\n readonly connectionId: string\n readonly revision: number\n readonly digest: string\n readonly offers: readonly {\n readonly endpoint: ConnectionEndpointReference\n readonly revision: number\n }[]\n readonly compatible: boolean\n readonly protocols: readonly NegotiatedProtocol[]\n readonly bindings: readonly CapabilityBinding[]\n readonly issues: readonly ConnectionIssue[]\n}\n\nexport interface ResolveConnectionOptions {\n readonly connectionId: string\n readonly revision: number\n readonly protocols: ProtocolCatalog\n readonly policy?: unknown\n}\n\n/** Policy envelope supplied to definitions while evaluating a pair of endpoint offers. */\nexport interface ConnectionNegotiationPolicy {\n readonly endpointByParticipant: Readonly<Record<string, string>>\n readonly protocol?: unknown\n}\n\nexport function createEndpointOffer(\n endpoint: EndpointIdentity,\n revision: number,\n declarations: readonly ProtocolDeclaration[],\n): EndpointOffer {\n validateEndpoint(endpoint)\n validateOfferRevision(revision)\n const seen = new Set<string>()\n const normalized = declarations.map(declaration => defineProtocolDeclaration(declaration))\n for (const declaration of normalized) {\n if (seen.has(declaration.participant.id)) throw new TypeError(`duplicate endpoint participant ${JSON.stringify(declaration.participant.id)}`)\n seen.add(declaration.participant.id)\n }\n return Object.freeze({\n apiVersion: CONNECTION_API_VERSION,\n kind: 'ConnectionOffer',\n endpoint: freezeEndpoint(endpoint),\n revision,\n declarations: Object.freeze(normalized),\n })\n}\n\nexport function validateEndpointOffer(offer: EndpointOffer): void {\n if (offer.apiVersion !== CONNECTION_API_VERSION || offer.kind !== 'ConnectionOffer') throw new TypeError('endpoint offer version or kind is unsupported')\n validateEndpoint(offer.endpoint)\n validateOfferRevision(offer.revision)\n if (!Array.isArray(offer.declarations)) throw new TypeError('endpoint offer declarations must be an array')\n const seen = new Set<string>()\n for (const declaration of offer.declarations) {\n validateProtocolDeclaration(declaration)\n if (seen.has(declaration.participant.id)) throw new TypeError(`duplicate endpoint participant ${JSON.stringify(declaration.participant.id)}`)\n seen.add(declaration.participant.id)\n }\n}\n\nexport function freezeEndpoint(endpoint: EndpointIdentity): ConnectionEndpointReference {\n return Object.freeze({ id: endpoint.id, instanceId: endpoint.instanceId })\n}\n\nexport function validatePlanCoordinates(connectionId: string, revision: number): void {\n nonEmpty(connectionId, 'connectionId')\n if (!Number.isSafeInteger(revision) || revision < 1) throw new TypeError('connection revision must be a positive safe integer')\n}\n\nfunction validateEndpoint(endpoint: EndpointIdentity): void {\n nonEmpty(endpoint.id, 'endpoint.id')\n nonEmpty(endpoint.instanceId, 'endpoint.instanceId')\n}\n\nfunction validateOfferRevision(revision: number): void {\n if (!Number.isSafeInteger(revision) || revision < 0) throw new TypeError('offer revision must be a non-negative safe integer')\n}\n\nfunction nonEmpty(value: string, label: string): void {\n if (typeof value !== 'string' || value.trim() === '') throw new TypeError(`${label} must be a non-empty string`)\n}\n","import type { ApiReference, ProtocolSupport } from '@dsh-std/core'\nimport type { CapabilityBinding, ConnectionEndpointReference, ConnectionPlan, EndpointOffer } from './model.js'\n\nexport interface CapabilityHandlerContext<TProgress = unknown> {\n readonly connectionId: string\n readonly planRevision: number\n readonly invocationId: string\n readonly binding: CapabilityBinding\n readonly signal: AbortSignal\n progress(value: TProgress): void\n}\n\nexport type CapabilityHandler<TInput = unknown, TOutput = unknown, TProgress = unknown> = (\n operation: string, input: TInput, context: CapabilityHandlerContext<TProgress>,\n) => TOutput | Promise<TOutput>\n\nexport interface CapabilityImplementation<TInput = unknown, TOutput = unknown, TProgress = unknown> {\n readonly participantId: string\n readonly protocol: ProtocolSupport\n readonly handle: CapabilityHandler<TInput, TOutput, TProgress>\n}\n\nexport interface CapabilityDispatch<TInput = unknown, TProgress = unknown> {\n readonly connectionId: string\n readonly planRevision: number\n readonly invocationId: string\n readonly binding: CapabilityBinding\n readonly operation: string\n readonly input: TInput\n readonly signal: AbortSignal\n progress(value: TProgress): void\n}\n\nexport interface ConnectionEndpoint {\n readonly offer: EndpointOffer\n dispatch<TInput = unknown, TOutput = unknown, TProgress = unknown>(invocation: CapabilityDispatch<TInput, TProgress>): Promise<TOutput>\n onOfferChange(listener: (offer: EndpointOffer) => void): () => void\n}\n\nexport interface CapabilityCall<TOutput = unknown, TProgress = unknown> {\n readonly invocationId: string\n readonly result: Promise<TOutput>\n readonly progress: AsyncIterable<TProgress>\n cancel(reason?: string): void\n}\n\nexport interface CapabilityClient {\n readonly participantId: string\n binding(reference: ApiReference): CapabilityBinding | undefined\n invoke<TInput = unknown, TOutput = unknown, TProgress = unknown>(\n reference: ApiReference,\n operation: string,\n input: TInput,\n options?: { readonly signal?: AbortSignal },\n ): CapabilityCall<TOutput, TProgress>\n}\n\nexport interface StandardConnection {\n readonly id: string\n readonly local: ConnectionEndpointReference\n readonly remote: ConnectionEndpointReference\n readonly plan: ConnectionPlan\n client(participantId: string): CapabilityClient\n onPlanChange(listener: (plan: ConnectionPlan) => void): () => void\n close(reason?: string): void | Promise<void>\n}\n\nexport class ConnectionInvocationError extends Error {\n constructor(\n readonly code: 'connection-closed' | 'capability-unbound' | 'handler-missing' | 'cancelled' | 'handler-failed',\n message: string,\n options?: ErrorOptions,\n ) {\n super(message, options)\n this.name = 'ConnectionInvocationError'\n }\n}\n","import type {\n ProtocolDefinition,\n ProtocolIssue,\n ProtocolRequirement,\n ProtocolSupport,\n} from '@dsh-std/core'\nimport type { ConnectionNegotiationPolicy } from './model.js'\n\nexport interface CapabilityBindingDraft {\n readonly consumer: string\n readonly provider: string\n readonly requirement: ProtocolRequirement\n readonly support: ProtocolSupport\n}\n\nexport interface CapabilityAgreement {\n readonly kind: 'CapabilityBindings'\n readonly bindings: readonly CapabilityBindingDraft[]\n}\n\nexport interface CapabilityProtocolOptions {\n readonly apiVersion: string\n readonly kind: string\n readonly accepts?: readonly string[]\n readonly multipleProviders?: boolean\n validateRequirement?(spec: unknown): unknown\n validateSupport?(spec: unknown): unknown\n}\n\n/** Reusable RPC-shaped protocol definition. Domain packages opt into these semantics explicitly. */\nexport function defineCapabilityProtocol(options: CapabilityProtocolOptions): ProtocolDefinition {\n const definition: ProtocolDefinition = {\n apiVersion: options.apiVersion,\n kind: options.kind,\n ...(options.accepts === undefined ? {} : { accepts: Object.freeze([...options.accepts]) }),\n validateRequirement: options.validateRequirement ?? ((value: unknown) => value),\n validateSupport: options.validateSupport ?? ((value: unknown) => value),\n negotiate(input) {\n const issues: ProtocolIssue[] = []\n const bindings: CapabilityBindingDraft[] = []\n const connectionPolicy = isConnectionPolicy(input.policy) ? input.policy : undefined\n for (const row of input.requirements) {\n const consumerEndpoint = connectionPolicy?.endpointByParticipant[row.participant]\n const providers = input.supports.filter(candidate =>\n candidate.participant !== row.participant\n && (consumerEndpoint === undefined\n || connectionPolicy?.endpointByParticipant[candidate.participant] !== consumerEndpoint),\n )\n if (providers.length === 0) {\n issues.push(Object.freeze({\n code: row.requirement.optional === true ? 'optional-support-missing' : 'required-support-missing',\n severity: row.requirement.optional === true ? 'warning' : 'error',\n participant: row.participant,\n message: `no participant supports ${row.requirement.apiVersion} ${row.requirement.kind}`,\n }))\n continue\n }\n if (providers.length > 1 && options.multipleProviders !== true) {\n issues.push(Object.freeze({\n code: 'support-ambiguous', severity: 'error', participant: row.participant,\n message: `multiple participants support ${row.requirement.apiVersion} ${row.requirement.kind}`,\n }))\n continue\n }\n for (const provider of options.multipleProviders === true ? providers : providers.slice(0, 1)) {\n bindings.push(Object.freeze({\n consumer: row.participant,\n provider: provider.participant,\n requirement: row.requirement,\n support: provider.support,\n }))\n }\n }\n return {\n agreement: Object.freeze({ kind: 'CapabilityBindings' as const, bindings: Object.freeze(bindings) }),\n issues: Object.freeze(issues),\n }\n },\n }\n return Object.freeze(definition)\n}\n\nfunction isConnectionPolicy(value: unknown): value is ConnectionNegotiationPolicy {\n return typeof value === 'object' && value !== null\n && typeof (value as { endpointByParticipant?: unknown }).endpointByParticipant === 'object'\n && (value as { endpointByParticipant?: unknown }).endpointByParticipant !== null\n}\n\nexport function isCapabilityAgreement(value: unknown): value is CapabilityAgreement {\n return typeof value === 'object' && value !== null\n && (value as { kind?: unknown }).kind === 'CapabilityBindings'\n && Array.isArray((value as { bindings?: unknown }).bindings)\n}\n","import type { ProtocolIssue } from '@dsh-std/core'\nimport {\n CONNECTION_API_VERSION,\n freezeEndpoint,\n validateEndpointOffer,\n validatePlanCoordinates,\n type CapabilityBinding,\n type CapabilityParticipant,\n type ConnectionIssue,\n type ConnectionPlan,\n type ConnectionNegotiationPolicy,\n type EndpointOffer,\n type ResolveConnectionOptions,\n} from './model.js'\nimport { isCapabilityAgreement } from './rpc.js'\n\nexport function resolveConnection(left: EndpointOffer, right: EndpointOffer, options: ResolveConnectionOptions): ConnectionPlan {\n validateEndpointOffer(left)\n validateEndpointOffer(right)\n validatePlanCoordinates(options.connectionId, options.revision)\n if (left.endpoint.instanceId === right.endpoint.instanceId) throw new TypeError('connection endpoints must have distinct instanceId values')\n\n const owner = participantOwners(left, right)\n const endpointByParticipant = Object.freeze(Object.fromEntries(\n [...owner.entries()].map(([participant, row]) => [participant, row.endpoint.instanceId]),\n ))\n const policy: ConnectionNegotiationPolicy = Object.freeze({\n endpointByParticipant,\n ...(options.policy === undefined ? {} : { protocol: options.policy }),\n })\n const report = options.protocols.negotiate([...left.declarations, ...right.declarations], policy)\n const bindings: CapabilityBinding[] = []\n for (const protocol of report.protocols) {\n if (!isCapabilityAgreement(protocol.agreement)) continue\n for (const draft of protocol.agreement.bindings) {\n const consumer = owner.get(draft.consumer)\n const provider = owner.get(draft.provider)\n if (consumer === undefined || provider === undefined) continue\n bindings.push(Object.freeze({\n bindingId: '', agreementId: `${protocol.apiVersion}:${protocol.kind}`,\n planRevision: options.revision,\n consumer, provider,\n requirement: Object.freeze({ ...draft.requirement }),\n support: Object.freeze({ ...draft.support }),\n }))\n }\n }\n bindings.sort((a, b) => a.consumer.participantId.localeCompare(b.consumer.participantId)\n || a.requirement.apiVersion.localeCompare(b.requirement.apiVersion)\n || a.requirement.kind.localeCompare(b.requirement.kind)\n || a.provider.participantId.localeCompare(b.provider.participantId))\n const numbered = bindings.map((binding, index) => Object.freeze({ ...binding, bindingId: `binding-${String(index + 1)}` }))\n const issues = Object.freeze(report.issues.map(row => connectionIssue(row, owner)))\n const coordinates = Object.freeze([\n Object.freeze({ endpoint: freezeEndpoint(left.endpoint), revision: left.revision }),\n Object.freeze({ endpoint: freezeEndpoint(right.endpoint), revision: right.revision }),\n ])\n const digest = planDigest({ connectionId: options.connectionId, revision: options.revision, offers: coordinates, protocols: report.protocols })\n return Object.freeze({\n apiVersion: CONNECTION_API_VERSION,\n kind: 'ConnectionAgreement',\n connectionId: options.connectionId,\n revision: options.revision,\n digest,\n offers: coordinates,\n compatible: report.compatible,\n protocols: report.protocols,\n bindings: Object.freeze(numbered),\n issues,\n })\n}\n\nfunction planDigest(value: unknown): string {\n const input = canonical(value)\n let hash = 2166136261\n for (let index = 0; index < input.length; index += 1) hash = Math.imul(hash ^ input.charCodeAt(index), 16777619)\n return `fnv1a32:${(hash >>> 0).toString(16).padStart(8, '0')}`\n}\n\nfunction canonical(value: unknown): string {\n if (Array.isArray(value)) return `[${value.map(canonical).join(',')}]`\n if (typeof value === 'object' && value !== null) {\n return `{${Object.entries(value).sort(([a], [b]) => a.localeCompare(b)).map(([key, item]) => `${JSON.stringify(key)}:${canonical(item)}`).join(',')}}`\n }\n return JSON.stringify(value)\n}\n\nfunction participantOwners(left: EndpointOffer, right: EndpointOffer): Map<string, CapabilityParticipant> {\n const owners = new Map<string, CapabilityParticipant>()\n for (const offer of [left, right]) {\n for (const declaration of offer.declarations) {\n if (owners.has(declaration.participant.id)) throw new TypeError(`participant ${JSON.stringify(declaration.participant.id)} appears in both endpoint offers`)\n owners.set(declaration.participant.id, Object.freeze({\n endpoint: freezeEndpoint(offer.endpoint), participantId: declaration.participant.id,\n }))\n }\n }\n return owners\n}\n\nfunction connectionIssue(issue: ProtocolIssue, owners: ReadonlyMap<string, CapabilityParticipant>): ConnectionIssue {\n return Object.freeze({\n severity: issue.severity,\n code: issue.code,\n ...(issue.participant === undefined ? {} : {\n participant: owners.get(issue.participant) ?? Object.freeze({\n endpoint: Object.freeze({ id: 'unknown', instanceId: 'unknown' }), participantId: issue.participant,\n }),\n }),\n ...(issue.path === undefined ? {} : { path: issue.path }),\n message: issue.message,\n })\n}\n"],"mappings":";;AASA,MAAa,yBAAyB;AAqEtC,SAAgB,oBACd,UACA,UACA,cACe;CACf,iBAAiB,QAAQ;CACzB,sBAAsB,QAAQ;CAC9B,MAAM,uBAAO,IAAI,IAAY;CAC7B,MAAM,aAAa,aAAa,KAAI,gBAAe,0BAA0B,WAAW,CAAC;CACzF,KAAK,MAAM,eAAe,YAAY;EACpC,IAAI,KAAK,IAAI,YAAY,YAAY,EAAE,GAAG,MAAM,IAAI,UAAU,kCAAkC,KAAK,UAAU,YAAY,YAAY,EAAE,GAAG;EAC5I,KAAK,IAAI,YAAY,YAAY,EAAE;CACrC;CACA,OAAO,OAAO,OAAO;EACnB,YAAY;EACZ,MAAM;EACN,UAAU,eAAe,QAAQ;EACjC;EACA,cAAc,OAAO,OAAO,UAAU;CACxC,CAAC;AACH;AAEA,SAAgB,sBAAsB,OAA4B;CAChE,IAAI,MAAM,eAAA,6BAAyC,MAAM,SAAS,mBAAmB,MAAM,IAAI,UAAU,+CAA+C;CACxJ,iBAAiB,MAAM,QAAQ;CAC/B,sBAAsB,MAAM,QAAQ;CACpC,IAAI,CAAC,MAAM,QAAQ,MAAM,YAAY,GAAG,MAAM,IAAI,UAAU,8CAA8C;CAC1G,MAAM,uBAAO,IAAI,IAAY;CAC7B,KAAK,MAAM,eAAe,MAAM,cAAc;EAC5C,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I,EAAE,MAAM,MAAM,KAAK;EACvD,SAAS,MAAM;CACjB,CAAC;AACH"}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@dsh-std/connection",
|
|
3
|
-
"version": "0.1.0",
|
|
4
|
-
"license": "MIT",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"main": "lib/index.js",
|
|
7
|
-
"types": "lib/index.d.ts",
|
|
8
|
-
"exports": {
|
|
9
|
-
".": { "types": "./lib/index.d.ts", "default": "./lib/index.js" },
|
|
10
|
-
"./memory": { "types": "./lib/memory.d.ts", "default": "./lib/memory.js" }
|
|
11
|
-
},
|
|
12
|
-
"files": ["lib", "CHANGELOG.md"],
|
|
13
|
-
"scripts": {
|
|
14
|
-
"build": "pnpm run typecheck && tsdown",
|
|
15
|
-
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
16
|
-
"test": "vitest run"
|
|
17
|
-
},
|
|
18
|
-
"dependencies": { "@dsh-std/core": "workspace:*" },
|
|
19
|
-
"engines": { "node": "^22.19 || >=24" }
|
|
20
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@dsh-std/connection",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "lib/index.js",
|
|
7
|
+
"types": "lib/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": { "types": "./lib/index.d.ts", "default": "./lib/index.js" },
|
|
10
|
+
"./memory": { "types": "./lib/memory.d.ts", "default": "./lib/memory.js" }
|
|
11
|
+
},
|
|
12
|
+
"files": ["lib", "CHANGELOG.md"],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "pnpm run typecheck && tsdown",
|
|
15
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
16
|
+
"test": "vitest run"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": { "@dsh-std/core": "workspace:*" },
|
|
19
|
+
"engines": { "node": "^22.19 || >=24" }
|
|
20
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
Changes to `@dsh-std/core` are recorded here.
|
|
4
|
-
|
|
5
|
-
## 0.1.0 (draft)
|
|
6
|
-
|
|
7
|
-
- Defined protocol coordinates, participant declarations, definition catalogs, and negotiation reports.
|
|
8
|
-
- Separated evaluator knowledge, requirements, potential support, and live support.
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
Changes to `@dsh-std/core` are recorded here.
|
|
4
|
+
|
|
5
|
+
## 0.1.0 (draft)
|
|
6
|
+
|
|
7
|
+
- Defined protocol coordinates, participant declarations, definition catalogs, and negotiation reports.
|
|
8
|
+
- Separated evaluator knowledge, requirements, potential support, and live support.
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 DSH Standard contributors
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 DSH Standard contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
# @dsh-std/core
|
|
2
|
-
|
|
3
|
-
English | [中文](README.zh.md)
|
|
4
|
-
|
|
5
|
-
The minimal meta-protocol for protocol declarations, definition registration, and negotiation. See the [Core Meta-protocol proposal](../../docs/proposals/core.zh.md).
|
|
6
|
-
|
|
7
|
-
Core understands only `apiVersion`, `kind`, participants, requirements, supports, protocol definitions, and their agreements. It does not prescribe resources, capabilities, providers, execution planes, locality, endpoints, or plugin lifecycle.
|
|
8
|
-
|
|
9
|
-
A `ProtocolCatalog` belongs to an evaluator. Each protocol definition explicitly lists accepted API versions, validates requirement/support `spec` values, and owns its negotiation logic. Core neither infers compatibility from a shared major version nor treats an installed definition as a live implementation.
|
|
10
|
-
|
|
11
|
-
`defineProtocolDeclaration()` validates and freezes the requirements and supports currently published by one participant. Static component bounds belong to `@dsh-std/manifest`, selection to `@dsh-std/composition`, activation and the publication barrier to `@dsh-std/lifecycle`, and cross-endpoint offers to `@dsh-std/connection`.
|
|
12
|
-
|
|
13
|
-
Provider selection, multi-party merging, catalogs, invocation bindings, and UI semantics remain owned by their protocol definitions or domain packages.
|
|
1
|
+
# @dsh-std/core
|
|
2
|
+
|
|
3
|
+
English | [中文](README.zh.md)
|
|
4
|
+
|
|
5
|
+
The minimal meta-protocol for protocol declarations, definition registration, and negotiation. See the [Core Meta-protocol proposal](../../docs/proposals/core.zh.md).
|
|
6
|
+
|
|
7
|
+
Core understands only `apiVersion`, `kind`, participants, requirements, supports, protocol definitions, and their agreements. It does not prescribe resources, capabilities, providers, execution planes, locality, endpoints, or plugin lifecycle.
|
|
8
|
+
|
|
9
|
+
A `ProtocolCatalog` belongs to an evaluator. Each protocol definition explicitly lists accepted API versions, validates requirement/support `spec` values, and owns its negotiation logic. Core neither infers compatibility from a shared major version nor treats an installed definition as a live implementation.
|
|
10
|
+
|
|
11
|
+
`defineProtocolDeclaration()` validates and freezes the requirements and supports currently published by one participant. Static component bounds belong to `@dsh-std/manifest`, selection to `@dsh-std/composition`, activation and the publication barrier to `@dsh-std/lifecycle`, and cross-endpoint offers to `@dsh-std/connection`.
|
|
12
|
+
|
|
13
|
+
Provider selection, multi-party merging, catalogs, invocation bindings, and UI semantics remain owned by their protocol definitions or domain packages.
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
# @dsh-std/core
|
|
2
|
-
|
|
3
|
-
[English](README.md) | 中文
|
|
4
|
-
|
|
5
|
-
协议声明、definition 注册与协商的最小元协议。设计见 [Core Meta-protocol](../../docs/proposals/core.zh.md)。
|
|
6
|
-
|
|
7
|
-
Core 只认识 `apiVersion`、`kind`、participant、requirement、support、协议 definition 及其 agreement。它不预设 resource、capability、provider、execution plane、locality、endpoint 或插件生命周期。
|
|
8
|
-
|
|
9
|
-
`ProtocolCatalog` 由评估器持有。每个协议 definition 明确列出接受的 API 版本,分别校验 requirement/support 的 `spec`,并拥有自己的协商逻辑。Core 不会从相同主版本推断兼容性,也不会把安装了一份 definition 当作已有 live implementation。
|
|
10
|
-
|
|
11
|
-
`defineProtocolDeclaration()` 校验并冻结一个 participant 当前实际发布的 requirements 与 supports。静态组件上限属于 `@dsh-std/manifest`,选择属于 `@dsh-std/composition`,激活与 publication barrier 属于 `@dsh-std/lifecycle`,跨端点 offer 属于 `@dsh-std/connection`。
|
|
12
|
-
|
|
13
|
-
协议专属的 provider 选择、多项合并、目录、调用绑定和 UI 语义均由相应 definition 或独立协议包定义。
|
|
1
|
+
# @dsh-std/core
|
|
2
|
+
|
|
3
|
+
[English](README.md) | 中文
|
|
4
|
+
|
|
5
|
+
协议声明、definition 注册与协商的最小元协议。设计见 [Core Meta-protocol](../../docs/proposals/core.zh.md)。
|
|
6
|
+
|
|
7
|
+
Core 只认识 `apiVersion`、`kind`、participant、requirement、support、协议 definition 及其 agreement。它不预设 resource、capability、provider、execution plane、locality、endpoint 或插件生命周期。
|
|
8
|
+
|
|
9
|
+
`ProtocolCatalog` 由评估器持有。每个协议 definition 明确列出接受的 API 版本,分别校验 requirement/support 的 `spec`,并拥有自己的协商逻辑。Core 不会从相同主版本推断兼容性,也不会把安装了一份 definition 当作已有 live implementation。
|
|
10
|
+
|
|
11
|
+
`defineProtocolDeclaration()` 校验并冻结一个 participant 当前实际发布的 requirements 与 supports。静态组件上限属于 `@dsh-std/manifest`,选择属于 `@dsh-std/composition`,激活与 publication barrier 属于 `@dsh-std/lifecycle`,跨端点 offer 属于 `@dsh-std/connection`。
|
|
12
|
+
|
|
13
|
+
协议专属的 provider 选择、多项合并、目录、调用绑定和 UI 语义均由相应 definition 或独立协议包定义。
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["nonEmpty"],"sources":["../src/protocol.ts","../src/negotiation.ts","../src/version.ts"],"sourcesContent":["/** Domain-neutral protocol identities and live participant declarations. */\r\n\r\nexport interface ApiReference {\r\n readonly apiVersion: string\r\n readonly kind: string\r\n}\r\n\r\nexport interface ParticipantIdentity {\r\n /** Unique within the negotiation scope that carries this declaration. */\r\n readonly id: string\r\n}\r\n\r\nexport interface ProtocolRequirement<Spec = unknown> extends ApiReference {\r\n readonly optional?: boolean\r\n readonly spec?: Spec\r\n}\r\n\r\nexport interface ProtocolSupport<Spec = unknown> extends ApiReference {\r\n readonly spec?: Spec\r\n}\r\n\r\nexport interface ProtocolDeclaration {\r\n readonly participant: ParticipantIdentity\r\n readonly requires?: readonly ProtocolRequirement[]\r\n readonly supports?: readonly ProtocolSupport[]\r\n}\r\n\r\nexport interface ParsedApiVersion {\r\n readonly group: string\r\n readonly major: number\r\n readonly stability: 'alpha' | 'beta' | 'stable'\r\n readonly revision: number\r\n}\r\n\r\nexport function protocolKey(reference: ApiReference): string {\r\n return `${reference.apiVersion}\\0${reference.kind}`\r\n}\r\n\r\n/** A grouping key only. It does not claim that versions in the family interoperate. */\r\nexport function protocolFamilyKey(reference: ApiReference): string {\r\n const version = parseApiVersion(reference.apiVersion)\r\n return `${version.group}/v${version.major}\\0${reference.kind}`\r\n}\r\n\r\nexport function sameProtocol(left: ApiReference, right: ApiReference): boolean {\r\n return left.apiVersion === right.apiVersion && left.kind === right.kind\r\n}\r\n\r\nexport function parseApiVersion(value: string): ParsedApiVersion {\r\n const match = /^([a-z][a-z0-9.-]*)\\/v([1-9][0-9]*)(?:(alpha|beta)([1-9][0-9]*))?$/u.exec(value)\r\n if (match === null) throw new TypeError(`invalid apiVersion ${JSON.stringify(value)}`)\r\n return Object.freeze({\r\n group: match[1] as string,\r\n major: Number(match[2]),\r\n stability: (match[3] ?? 'stable') as ParsedApiVersion['stability'],\r\n revision: match[4] === undefined ? 0 : Number(match[4]),\r\n })\r\n}\r\n\r\nexport function validateApiReference(value: unknown, label = 'protocol reference'): asserts value is ApiReference {\r\n if (!record(value)) throw new TypeError(`${label} must be an object`)\r\n if (typeof value.apiVersion !== 'string') throw new TypeError(`${label}.apiVersion must be a string`)\r\n parseApiVersion(value.apiVersion)\r\n if (typeof value.kind !== 'string' || !/^[A-Z][A-Za-z0-9]*$/u.test(value.kind)) {\r\n throw new TypeError(`${label}.kind is invalid`)\r\n }\r\n}\r\n\r\nexport function validateProtocolDeclaration(value: unknown): asserts value is ProtocolDeclaration {\r\n if (!record(value)) throw new TypeError('protocol declaration must be an object')\r\n exact(value, ['participant', 'requires', 'supports'], 'protocol declaration')\r\n if (!record(value.participant)) throw new TypeError('protocol declaration participant must be an object')\r\n exact(value.participant, ['id'], 'participant identity')\r\n nonEmpty(value.participant.id, 'participant identity.id')\r\n validateRows(value.requires, true)\r\n validateRows(value.supports, false)\r\n}\r\n\r\nexport function defineProtocolDeclaration<const T extends ProtocolDeclaration>(declaration: T): T {\r\n validateProtocolDeclaration(declaration)\r\n return deepFreeze(structuredClone(declaration))\r\n}\r\n\r\nfunction validateRows(value: unknown, requirement: boolean): void {\r\n if (value === undefined) return\r\n const label = requirement ? 'protocol requirements' : 'protocol supports'\r\n if (!Array.isArray(value)) throw new TypeError(`${label} must be an array`)\r\n const seen = new Set<string>()\r\n for (const [index, rowValue] of value.entries()) {\r\n const rowLabel = `${label}[${index}]`\r\n validateApiReference(rowValue, rowLabel)\r\n const row = rowValue as unknown as Record<string, unknown>\r\n exact(row, requirement ? ['apiVersion', 'kind', 'optional', 'spec'] : ['apiVersion', 'kind', 'spec'], rowLabel)\r\n if (requirement && row.optional !== undefined && typeof row.optional !== 'boolean') {\r\n throw new TypeError(`${rowLabel}.optional must be boolean`)\r\n }\r\n const key = protocolKey(row as unknown as ApiReference)\r\n if (seen.has(key)) throw new TypeError(`${label} contains duplicate ${JSON.stringify(key)}`)\r\n seen.add(key)\r\n }\r\n}\r\n\r\nfunction nonEmpty(value: unknown, label: string): asserts value is string {\r\n if (typeof value !== 'string' || value.trim() === '') throw new TypeError(`${label} must be a non-empty string`)\r\n}\r\n\r\nfunction record(value: unknown): value is Record<string, unknown> {\r\n return typeof value === 'object' && value !== null && !Array.isArray(value)\r\n}\r\n\r\nfunction exact(value: Record<string, unknown>, allowed: readonly string[], label: string): void {\r\n const unknown = Object.keys(value).filter(key => !allowed.includes(key) && !key.startsWith('x-'))\r\n if (unknown.length > 0) throw new TypeError(`${label} contains unknown field ${JSON.stringify(unknown[0])}`)\r\n}\r\n\r\nfunction deepFreeze<T>(value: T): T {\r\n if (typeof value !== 'object' || value === null || Object.isFrozen(value)) return value\r\n Object.freeze(value)\r\n for (const child of Object.values(value)) deepFreeze(child)\r\n return value\r\n}\r\n","import {\r\n protocolKey,\r\n validateApiReference,\r\n validateProtocolDeclaration,\r\n type ApiReference,\r\n type ProtocolDeclaration,\r\n type ProtocolRequirement,\r\n type ProtocolSupport,\r\n} from './protocol.js'\r\n\r\nexport interface EvaluatorIdentity {\r\n readonly name: string\r\n readonly version: string\r\n}\r\n\r\nexport interface ProtocolRequirementEntry<Spec = unknown> {\r\n readonly participant: string\r\n readonly requirement: ProtocolRequirement<Spec>\r\n}\r\n\r\nexport interface ProtocolSupportEntry<Spec = unknown> {\r\n readonly participant: string\r\n readonly support: ProtocolSupport<Spec>\r\n}\r\n\r\nexport interface ProtocolIssue {\r\n readonly code: string\r\n readonly severity: 'error' | 'warning'\r\n readonly participant?: string\r\n readonly path?: string\r\n readonly message: string\r\n}\r\n\r\nexport interface ProtocolNegotiationInput<RequirementSpec = unknown, SupportSpec = unknown, Policy = unknown> {\r\n readonly requirements: readonly ProtocolRequirementEntry<RequirementSpec>[]\r\n readonly supports: readonly ProtocolSupportEntry<SupportSpec>[]\r\n readonly policy?: Policy\r\n}\r\n\r\nexport interface ProtocolNegotiationOutcome<Agreement = unknown> {\r\n readonly agreement?: Agreement\r\n readonly issues?: readonly ProtocolIssue[]\r\n}\r\n\r\nexport interface ProtocolDefinition<RequirementSpec = unknown, SupportSpec = unknown, Agreement = unknown, Policy = unknown>\r\n extends ApiReference {\r\n /** Every accepted wire/static API version. No compatibility is inferred by core. */\r\n readonly accepts?: readonly string[]\r\n validateRequirement(spec: unknown): RequirementSpec\r\n validateSupport(spec: unknown): SupportSpec\r\n negotiate(\r\n input: ProtocolNegotiationInput<RequirementSpec, SupportSpec, Policy>,\r\n ): ProtocolNegotiationOutcome<Agreement>\r\n}\r\n\r\nexport interface NegotiatedProtocol<Agreement = unknown> extends ApiReference {\r\n readonly participants: readonly string[]\r\n readonly agreement?: Agreement\r\n readonly issues: readonly ProtocolIssue[]\r\n}\r\n\r\nexport interface NegotiationReport {\r\n readonly apiVersion: 'core.dsh/report/v1alpha1'\r\n readonly evaluator: EvaluatorIdentity\r\n readonly compatible: boolean\r\n readonly protocols: readonly NegotiatedProtocol[]\r\n readonly issues: readonly ProtocolIssue[]\r\n}\r\n\r\ninterface StoredDefinition {\r\n readonly definition: ProtocolDefinition\r\n readonly accepted: ReadonlySet<string>\r\n}\r\n\r\nexport class ProtocolCatalog {\r\n private readonly definitions = new Map<string, StoredDefinition>()\r\n\r\n constructor(readonly evaluator: EvaluatorIdentity) {\r\n nonEmpty(evaluator.name, 'evaluator.name')\r\n nonEmpty(evaluator.version, 'evaluator.version')\r\n }\r\n\r\n register(definition: ProtocolDefinition): () => void {\r\n validateDefinition(definition)\r\n const accepted = new Set([definition.apiVersion, ...(definition.accepts ?? [])])\r\n for (const version of accepted) {\r\n const key = protocolKey({ apiVersion: version, kind: definition.kind })\r\n if (this.definitions.has(key)) {\r\n throw new Error(`protocol definition for ${version} ${definition.kind} is already registered`)\r\n }\r\n }\r\n const stored = Object.freeze({ definition: freezeDefinition(definition), accepted: new Set(accepted) })\r\n for (const version of accepted) this.definitions.set(protocolKey({ apiVersion: version, kind: definition.kind }), stored)\r\n return () => {\r\n for (const version of accepted) {\r\n const key = protocolKey({ apiVersion: version, kind: definition.kind })\r\n if (this.definitions.get(key) === stored) this.definitions.delete(key)\r\n }\r\n }\r\n }\r\n\r\n list(): readonly ProtocolDefinition[] {\r\n return Object.freeze([...new Set([...this.definitions.values()].map(row => row.definition))])\r\n }\r\n\r\n resolve(reference: ApiReference): ProtocolDefinition | undefined {\r\n validateApiReference(reference)\r\n return this.definitions.get(protocolKey(reference))?.definition\r\n }\r\n\r\n understands(reference: ApiReference): boolean {\r\n return this.resolve(reference) !== undefined\r\n }\r\n\r\n negotiate(declarations: readonly ProtocolDeclaration[], policy?: unknown): NegotiationReport {\r\n const participantIds = new Set<string>()\r\n for (const declaration of declarations) {\r\n validateProtocolDeclaration(declaration)\r\n if (participantIds.has(declaration.participant.id)) {\r\n throw new TypeError(`duplicate participant identity ${JSON.stringify(declaration.participant.id)}`)\r\n }\r\n participantIds.add(declaration.participant.id)\r\n }\r\n\r\n const groups = new Map<StoredDefinition, {\r\n requirements: ProtocolRequirementEntry[]\r\n supports: ProtocolSupportEntry[]\r\n }>()\r\n const issues: ProtocolIssue[] = []\r\n for (const [declarationIndex, declaration] of declarations.entries()) {\r\n for (const [index, requirement] of (declaration.requires ?? []).entries()) {\r\n const stored = this.definitions.get(protocolKey(requirement))\r\n if (stored === undefined) {\r\n issues.push(freezeIssue({\r\n code: 'definition-unavailable',\r\n severity: requirement.optional === true ? 'warning' : 'error',\r\n participant: declaration.participant.id,\r\n path: `/declarations/${declarationIndex}/requires/${index}`,\r\n message: `no definition recognizes ${requirement.apiVersion} ${requirement.kind}`,\r\n }))\r\n continue\r\n }\r\n const group = groups.get(stored) ?? { requirements: [], supports: [] }\r\n try {\r\n group.requirements.push(Object.freeze({\r\n participant: declaration.participant.id,\r\n requirement: Object.freeze({\r\n ...requirement,\r\n ...(Object.hasOwn(requirement, 'spec')\r\n ? { spec: stored.definition.validateRequirement(requirement.spec) }\r\n : { spec: stored.definition.validateRequirement(undefined) }),\r\n }),\r\n }))\r\n } catch (error) {\r\n issues.push(freezeIssue({\r\n code: 'invalid-requirement', severity: 'error', participant: declaration.participant.id,\r\n path: `/declarations/${declarationIndex}/requires/${index}/spec`, message: errorMessage(error),\r\n }))\r\n }\r\n groups.set(stored, group)\r\n }\r\n for (const [index, support] of (declaration.supports ?? []).entries()) {\r\n const stored = this.definitions.get(protocolKey(support))\r\n if (stored === undefined) {\r\n issues.push(freezeIssue({\r\n code: 'definition-unavailable', severity: 'warning', participant: declaration.participant.id,\r\n path: `/declarations/${declarationIndex}/supports/${index}`,\r\n message: `no definition recognizes ${support.apiVersion} ${support.kind}`,\r\n }))\r\n continue\r\n }\r\n const group = groups.get(stored) ?? { requirements: [], supports: [] }\r\n try {\r\n group.supports.push(Object.freeze({\r\n participant: declaration.participant.id,\r\n support: Object.freeze({\r\n ...support,\r\n ...(Object.hasOwn(support, 'spec')\r\n ? { spec: stored.definition.validateSupport(support.spec) }\r\n : { spec: stored.definition.validateSupport(undefined) }),\r\n }),\r\n }))\r\n } catch (error) {\r\n issues.push(freezeIssue({\r\n code: 'invalid-support', severity: 'error', participant: declaration.participant.id,\r\n path: `/declarations/${declarationIndex}/supports/${index}/spec`, message: errorMessage(error),\r\n }))\r\n }\r\n groups.set(stored, group)\r\n }\r\n }\r\n\r\n const protocols: NegotiatedProtocol[] = []\r\n for (const stored of [...groups.keys()].sort((left, right) => protocolKey(left.definition).localeCompare(protocolKey(right.definition)))) {\r\n const group = groups.get(stored) as NonNullable<ReturnType<typeof groups.get>>\r\n let outcome: ProtocolNegotiationOutcome\r\n try {\r\n outcome = stored.definition.negotiate(Object.freeze({\r\n requirements: Object.freeze([...group.requirements]),\r\n supports: Object.freeze([...group.supports]),\r\n ...(policy === undefined ? {} : { policy }),\r\n }))\r\n } catch (error) {\r\n outcome = { issues: [{ code: 'definition-failed', severity: 'error', message: errorMessage(error) }] }\r\n }\r\n const protocolIssues = Object.freeze((outcome.issues ?? []).map(freezeIssue))\r\n issues.push(...protocolIssues)\r\n protocols.push(Object.freeze({\r\n apiVersion: stored.definition.apiVersion,\r\n kind: stored.definition.kind,\r\n participants: Object.freeze([...new Set([\r\n ...group.requirements.map(row => row.participant),\r\n ...group.supports.map(row => row.participant),\r\n ])].sort()),\r\n ...(Object.hasOwn(outcome, 'agreement') ? { agreement: outcome.agreement } : {}),\r\n issues: protocolIssues,\r\n }))\r\n }\r\n\r\n return Object.freeze({\r\n apiVersion: 'core.dsh/report/v1alpha1',\r\n evaluator: Object.freeze({ ...this.evaluator }),\r\n compatible: !issues.some(issue => issue.severity === 'error'),\r\n protocols: Object.freeze(protocols),\r\n issues: Object.freeze(issues),\r\n })\r\n }\r\n}\r\n\r\nfunction validateDefinition(definition: ProtocolDefinition): void {\r\n validateApiReference(definition, 'protocol definition')\r\n if (typeof definition.validateRequirement !== 'function'\r\n || typeof definition.validateSupport !== 'function'\r\n || typeof definition.negotiate !== 'function') {\r\n throw new TypeError('protocol definition must provide validators and negotiate')\r\n }\r\n const versions = [definition.apiVersion, ...(definition.accepts ?? [])]\r\n if (new Set(versions).size !== versions.length) throw new TypeError('protocol definition accepts duplicate versions')\r\n for (const version of versions) validateApiReference({ apiVersion: version, kind: definition.kind })\r\n}\r\n\r\nfunction freezeDefinition(definition: ProtocolDefinition): ProtocolDefinition {\r\n return Object.freeze({ ...definition, ...(definition.accepts === undefined ? {} : { accepts: Object.freeze([...definition.accepts]) }) })\r\n}\r\n\r\nfunction freezeIssue(issue: ProtocolIssue): ProtocolIssue {\r\n if (issue.severity !== 'error' && issue.severity !== 'warning') throw new TypeError('protocol issue severity is invalid')\r\n nonEmpty(issue.code, 'protocol issue.code')\r\n nonEmpty(issue.message, 'protocol issue.message')\r\n return Object.freeze({ ...issue })\r\n}\r\n\r\nfunction nonEmpty(value: unknown, label: string): asserts value is string {\r\n if (typeof value !== 'string' || value.trim() === '') throw new TypeError(`${label} must be a non-empty string`)\r\n}\r\n\r\nfunction errorMessage(error: unknown): string {\r\n return error instanceof Error ? error.message : String(error)\r\n}\r\n","export interface SemanticVersion {\r\n readonly major: number\r\n readonly minor: number\r\n readonly patch: number\r\n readonly prerelease: readonly (string | number)[]\r\n readonly build: readonly string[]\r\n}\r\n\r\nexport type VersionRange = string | readonly string[]\r\n\r\nexport function parseSemanticVersion(value: string): SemanticVersion {\r\n const match = /^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-([0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*))?(?:\\+([0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*))?$/u.exec(value)\r\n if (match === null) throw new TypeError(`invalid semantic version ${JSON.stringify(value)}`)\r\n const prerelease = match[4] === undefined ? [] : match[4].split('.').map(identifier => {\r\n if (!/^\\d+$/u.test(identifier)) return identifier\r\n if (identifier.length > 1 && identifier.startsWith('0')) throw new TypeError(`invalid semantic version ${JSON.stringify(value)}`)\r\n return Number(identifier)\r\n })\r\n return Object.freeze({\r\n major: Number(match[1]), minor: Number(match[2]), patch: Number(match[3]),\r\n prerelease: Object.freeze(prerelease),\r\n build: Object.freeze(match[5] === undefined ? [] : match[5].split('.')),\r\n })\r\n}\r\n\r\nexport function compareSemanticVersions(leftValue: string | SemanticVersion, rightValue: string | SemanticVersion): number {\r\n const left = typeof leftValue === 'string' ? parseSemanticVersion(leftValue) : leftValue\r\n const right = typeof rightValue === 'string' ? parseSemanticVersion(rightValue) : rightValue\r\n return left.major - right.major\r\n || left.minor - right.minor\r\n || left.patch - right.patch\r\n || comparePrerelease(left.prerelease, right.prerelease)\r\n}\r\n\r\nexport function assertVersionRange(range: VersionRange): void {\r\n compileRange(range)\r\n}\r\n\r\nexport function satisfiesVersionRange(versionValue: string, range: VersionRange): boolean {\r\n const version = parseSemanticVersion(versionValue)\r\n return compileRange(range).some(group => {\r\n if (version.prerelease.length > 0 && !group.explicitPrereleases.has(coreKey(version))) return false\r\n return group.predicates.every(predicate => predicate(version))\r\n })\r\n}\r\n\r\ninterface ComparatorGroup {\r\n readonly predicates: readonly ((version: SemanticVersion) => boolean)[]\r\n readonly explicitPrereleases: ReadonlySet<string>\r\n}\r\n\r\nfunction compileRange(range: VersionRange): readonly ComparatorGroup[] {\r\n const values = typeof range === 'string' ? [range] : range\r\n if (!Array.isArray(values) || values.length === 0) throw new TypeError('version range must be a string or non-empty array')\r\n return Object.freeze(values.flatMap(value => {\r\n if (typeof value !== 'string' || value.trim() === '') throw new TypeError('version range must not be empty')\r\n return value.split('||').map(part => compileGroup(part.trim()))\r\n }))\r\n}\r\n\r\nfunction compileGroup(value: string): ComparatorGroup {\r\n if (value === '') throw new TypeError('version range contains an empty alternative')\r\n if (value === '*' || /^x$/iu.test(value)) return { predicates: [], explicitPrereleases: new Set() }\r\n const predicates: Array<(version: SemanticVersion) => boolean> = []\r\n const explicitPrereleases = new Set<string>()\r\n for (const token of value.split(/\\s+/u)) {\r\n const parsed = compileComparator(token)\r\n predicates.push(...parsed.predicates)\r\n if (parsed.explicitPrerelease !== undefined) explicitPrereleases.add(parsed.explicitPrerelease)\r\n }\r\n return Object.freeze({ predicates: Object.freeze(predicates), explicitPrereleases })\r\n}\r\n\r\nfunction compileComparator(token: string): {\r\n readonly predicates: readonly ((version: SemanticVersion) => boolean)[]\r\n readonly explicitPrerelease?: string\r\n} {\r\n const match = /^(<=|>=|<|>|=|\\^|~)?(.+)$/u.exec(token)\r\n if (match === null) throw new TypeError(`invalid version comparator ${JSON.stringify(token)}`)\r\n const operator = match[1] ?? '='\r\n const body = match[2] as string\r\n const partial = /^(0|[1-9]\\d*|[xX*])(?:\\.(0|[1-9]\\d*|[xX*]))?(?:\\.(0|[1-9]\\d*|[xX*]))?$/u.exec(body)\r\n if (partial !== null && (partial[2] === undefined || partial[3] === undefined || [partial[1], partial[2], partial[3]].some(wild))) {\r\n if (operator !== '=') {\r\n if ((operator === '~' || operator === '^') && ![partial[1], partial[2]].some(wild)) {\r\n const lower = version(Number(partial[1]), Number(partial[2]), partial[3] === undefined || wild(partial[3]) ? 0 : Number(partial[3]))\r\n return bounded(lower, operator === '~' ? version(lower.major, lower.minor + 1, 0) : caretUpper(lower))\r\n }\r\n throw new TypeError(`partial version cannot use ${JSON.stringify(operator)}`)\r\n }\r\n return wildcardRange(partial)\r\n }\r\n\r\n const target = parseSemanticVersion(body)\r\n const explicitPrerelease = target.prerelease.length === 0 ? undefined : coreKey(target)\r\n if (operator === '^') return { ...bounded(target, caretUpper(target)), ...(explicitPrerelease === undefined ? {} : { explicitPrerelease }) }\r\n if (operator === '~') return { ...bounded(target, version(target.major, target.minor + 1, 0)), ...(explicitPrerelease === undefined ? {} : { explicitPrerelease }) }\r\n const comparison = (candidate: SemanticVersion) => compareSemanticVersions(candidate, target)\r\n const predicate = operator === '=' ? (candidate: SemanticVersion) => comparison(candidate) === 0\r\n : operator === '<' ? (candidate: SemanticVersion) => comparison(candidate) < 0\r\n : operator === '<=' ? (candidate: SemanticVersion) => comparison(candidate) <= 0\r\n : operator === '>' ? (candidate: SemanticVersion) => comparison(candidate) > 0\r\n : (candidate: SemanticVersion) => comparison(candidate) >= 0\r\n return { predicates: [predicate], ...(explicitPrerelease === undefined ? {} : { explicitPrerelease }) }\r\n}\r\n\r\nfunction wildcardRange(match: RegExpExecArray): { readonly predicates: readonly ((version: SemanticVersion) => boolean)[] } {\r\n if (wild(match[1])) return { predicates: [] }\r\n const major = Number(match[1])\r\n if (match[2] === undefined || wild(match[2])) return bounded(version(major, 0, 0), version(major + 1, 0, 0))\r\n const minor = Number(match[2])\r\n if (match[3] === undefined || wild(match[3])) return bounded(version(major, minor, 0), version(major, minor + 1, 0))\r\n throw new TypeError('unreachable complete version range')\r\n}\r\n\r\nfunction bounded(lower: SemanticVersion, upper: SemanticVersion): { readonly predicates: readonly ((version: SemanticVersion) => boolean)[] } {\r\n return { predicates: [\r\n candidate => compareSemanticVersions(candidate, lower) >= 0,\r\n candidate => compareSemanticVersions(candidate, upper) < 0,\r\n ] }\r\n}\r\n\r\nfunction caretUpper(lower: SemanticVersion): SemanticVersion {\r\n if (lower.major > 0) return version(lower.major + 1, 0, 0)\r\n if (lower.minor > 0) return version(0, lower.minor + 1, 0)\r\n return version(0, 0, lower.patch + 1)\r\n}\r\n\r\nfunction version(major: number, minor: number, patch: number): SemanticVersion {\r\n return { major, minor, patch, prerelease: [], build: [] }\r\n}\r\n\r\nfunction wild(value: string | undefined): boolean {\r\n return value === '*' || /^x$/iu.test(value ?? '')\r\n}\r\n\r\nfunction coreKey(value: SemanticVersion): string {\r\n return `${value.major}.${value.minor}.${value.patch}`\r\n}\r\n\r\nfunction comparePrerelease(left: readonly (string | number)[], right: readonly (string | number)[]): number {\r\n if (left.length === 0) return right.length === 0 ? 0 : 1\r\n if (right.length === 0) return -1\r\n for (let index = 0; index < Math.max(left.length, right.length); index += 1) {\r\n const leftPart = left[index]\r\n const rightPart = right[index]\r\n if (leftPart === undefined) return -1\r\n if (rightPart === undefined) return 1\r\n if (leftPart === rightPart) continue\r\n if (typeof leftPart === 'number' && typeof rightPart === 'string') return -1\r\n if (typeof leftPart === 'string' && typeof rightPart === 'number') return 1\r\n return leftPart < rightPart ? -1 : 1\r\n }\r\n return 0\r\n}\r\n"],"mappings":";AAkCA,SAAgB,YAAY,WAAiC;CAC3D,OAAO,GAAG,UAAU,WAAW,IAAI,UAAU;AAC/C;;AAGA,SAAgB,kBAAkB,WAAiC;CACjE,MAAM,UAAU,gBAAgB,UAAU,UAAU;CACpD,OAAO,GAAG,QAAQ,MAAM,IAAI,QAAQ,MAAM,IAAI,UAAU;AAC1D;AAEA,SAAgB,aAAa,MAAoB,OAA8B;CAC7E,OAAO,KAAK,eAAe,MAAM,cAAc,KAAK,SAAS,MAAM;AACrE;AAEA,SAAgB,gBAAgB,OAAiC;CAC/D,MAAM,QAAQ,sEAAsE,KAAK,KAAK;CAC9F,IAAI,UAAU,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,WAAW,GAAG,OAAO;CAC/B,KAAK,IAAI,QAAQ,GAAG,QAAQ,KAAK,IAAI,KAAK,QAAQ,MAAM,MAAM,GAAG,SAAS,GAAG;EAC3E,MAAM,WAAW,KAAK;EACtB,MAAM,YAAY,MAAM;EACxB,IAAI,aAAa,KAAA,GAAW,OAAO;EACnC,IAAI,cAAc,KAAA,GAAW,OAAO;EACpC,IAAI,aAAa,WAAW;EAC5B,IAAI,OAAO,aAAa,YAAY,OAAO,cAAc,UAAU,OAAO;EAC1E,IAAI,OAAO,aAAa,YAAY,OAAO,cAAc,UAAU,OAAO;EAC1E,OAAO,WAAW,YAAY,KAAK;CACrC;CACA,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["nonEmpty"],"sources":["../src/protocol.ts","../src/negotiation.ts","../src/version.ts"],"sourcesContent":["/** Domain-neutral protocol identities and live participant declarations. */\n\nexport interface ApiReference {\n readonly apiVersion: string\n readonly kind: string\n}\n\nexport interface ParticipantIdentity {\n /** Unique within the negotiation scope that carries this declaration. */\n readonly id: string\n}\n\nexport interface ProtocolRequirement<Spec = unknown> extends ApiReference {\n readonly optional?: boolean\n readonly spec?: Spec\n}\n\nexport interface ProtocolSupport<Spec = unknown> extends ApiReference {\n readonly spec?: Spec\n}\n\nexport interface ProtocolDeclaration {\n readonly participant: ParticipantIdentity\n readonly requires?: readonly ProtocolRequirement[]\n readonly supports?: readonly ProtocolSupport[]\n}\n\nexport interface ParsedApiVersion {\n readonly group: string\n readonly major: number\n readonly stability: 'alpha' | 'beta' | 'stable'\n readonly revision: number\n}\n\nexport function protocolKey(reference: ApiReference): string {\n return `${reference.apiVersion}\\0${reference.kind}`\n}\n\n/** A grouping key only. It does not claim that versions in the family interoperate. */\nexport function protocolFamilyKey(reference: ApiReference): string {\n const version = parseApiVersion(reference.apiVersion)\n return `${version.group}/v${version.major}\\0${reference.kind}`\n}\n\nexport function sameProtocol(left: ApiReference, right: ApiReference): boolean {\n return left.apiVersion === right.apiVersion && left.kind === right.kind\n}\n\nexport function parseApiVersion(value: string): ParsedApiVersion {\n const match = /^([a-z][a-z0-9.-]*)\\/v([1-9][0-9]*)(?:(alpha|beta)([1-9][0-9]*))?$/u.exec(value)\n if (match === null) throw new TypeError(`invalid apiVersion ${JSON.stringify(value)}`)\n return Object.freeze({\n group: match[1] as string,\n major: Number(match[2]),\n stability: (match[3] ?? 'stable') as ParsedApiVersion['stability'],\n revision: match[4] === undefined ? 0 : Number(match[4]),\n })\n}\n\nexport function validateApiReference(value: unknown, label = 'protocol reference'): asserts value is ApiReference {\n if (!record(value)) throw new TypeError(`${label} must be an object`)\n if (typeof value.apiVersion !== 'string') throw new TypeError(`${label}.apiVersion must be a string`)\n parseApiVersion(value.apiVersion)\n if (typeof value.kind !== 'string' || !/^[A-Z][A-Za-z0-9]*$/u.test(value.kind)) {\n throw new TypeError(`${label}.kind is invalid`)\n }\n}\n\nexport function validateProtocolDeclaration(value: unknown): asserts value is ProtocolDeclaration {\n if (!record(value)) throw new TypeError('protocol declaration must be an object')\n exact(value, ['participant', 'requires', 'supports'], 'protocol declaration')\n if (!record(value.participant)) throw new TypeError('protocol declaration participant must be an object')\n exact(value.participant, ['id'], 'participant identity')\n nonEmpty(value.participant.id, 'participant identity.id')\n validateRows(value.requires, true)\n validateRows(value.supports, false)\n}\n\nexport function defineProtocolDeclaration<const T extends ProtocolDeclaration>(declaration: T): T {\n validateProtocolDeclaration(declaration)\n return deepFreeze(structuredClone(declaration))\n}\n\nfunction validateRows(value: unknown, requirement: boolean): void {\n if (value === undefined) return\n const label = requirement ? 'protocol requirements' : 'protocol supports'\n if (!Array.isArray(value)) throw new TypeError(`${label} must be an array`)\n const seen = new Set<string>()\n for (const [index, rowValue] of value.entries()) {\n const rowLabel = `${label}[${index}]`\n validateApiReference(rowValue, rowLabel)\n const row = rowValue as unknown as Record<string, unknown>\n exact(row, requirement ? ['apiVersion', 'kind', 'optional', 'spec'] : ['apiVersion', 'kind', 'spec'], rowLabel)\n if (requirement && row.optional !== undefined && typeof row.optional !== 'boolean') {\n throw new TypeError(`${rowLabel}.optional must be boolean`)\n }\n const key = protocolKey(row as unknown as ApiReference)\n if (seen.has(key)) throw new TypeError(`${label} contains duplicate ${JSON.stringify(key)}`)\n seen.add(key)\n }\n}\n\nfunction nonEmpty(value: unknown, label: string): asserts value is string {\n if (typeof value !== 'string' || value.trim() === '') throw new TypeError(`${label} must be a non-empty string`)\n}\n\nfunction record(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\nfunction exact(value: Record<string, unknown>, allowed: readonly string[], label: string): void {\n const unknown = Object.keys(value).filter(key => !allowed.includes(key) && !key.startsWith('x-'))\n if (unknown.length > 0) throw new TypeError(`${label} contains unknown field ${JSON.stringify(unknown[0])}`)\n}\n\nfunction deepFreeze<T>(value: T): T {\n if (typeof value !== 'object' || value === null || Object.isFrozen(value)) return value\n Object.freeze(value)\n for (const child of Object.values(value)) deepFreeze(child)\n return value\n}\n","import {\n protocolKey,\n validateApiReference,\n validateProtocolDeclaration,\n type ApiReference,\n type ProtocolDeclaration,\n type ProtocolRequirement,\n type ProtocolSupport,\n} from './protocol.js'\n\nexport interface EvaluatorIdentity {\n readonly name: string\n readonly version: string\n}\n\nexport interface ProtocolRequirementEntry<Spec = unknown> {\n readonly participant: string\n readonly requirement: ProtocolRequirement<Spec>\n}\n\nexport interface ProtocolSupportEntry<Spec = unknown> {\n readonly participant: string\n readonly support: ProtocolSupport<Spec>\n}\n\nexport interface ProtocolIssue {\n readonly code: string\n readonly severity: 'error' | 'warning'\n readonly participant?: string\n readonly path?: string\n readonly message: string\n}\n\nexport interface ProtocolNegotiationInput<RequirementSpec = unknown, SupportSpec = unknown, Policy = unknown> {\n readonly requirements: readonly ProtocolRequirementEntry<RequirementSpec>[]\n readonly supports: readonly ProtocolSupportEntry<SupportSpec>[]\n readonly policy?: Policy\n}\n\nexport interface ProtocolNegotiationOutcome<Agreement = unknown> {\n readonly agreement?: Agreement\n readonly issues?: readonly ProtocolIssue[]\n}\n\nexport interface ProtocolDefinition<RequirementSpec = unknown, SupportSpec = unknown, Agreement = unknown, Policy = unknown>\n extends ApiReference {\n /** Every accepted wire/static API version. No compatibility is inferred by core. */\n readonly accepts?: readonly string[]\n validateRequirement(spec: unknown): RequirementSpec\n validateSupport(spec: unknown): SupportSpec\n negotiate(\n input: ProtocolNegotiationInput<RequirementSpec, SupportSpec, Policy>,\n ): ProtocolNegotiationOutcome<Agreement>\n}\n\nexport interface NegotiatedProtocol<Agreement = unknown> extends ApiReference {\n readonly participants: readonly string[]\n readonly agreement?: Agreement\n readonly issues: readonly ProtocolIssue[]\n}\n\nexport interface NegotiationReport {\n readonly apiVersion: 'core.dsh/report/v1alpha1'\n readonly evaluator: EvaluatorIdentity\n readonly compatible: boolean\n readonly protocols: readonly NegotiatedProtocol[]\n readonly issues: readonly ProtocolIssue[]\n}\n\ninterface StoredDefinition {\n readonly definition: ProtocolDefinition\n readonly accepted: ReadonlySet<string>\n}\n\nexport class ProtocolCatalog {\n private readonly definitions = new Map<string, StoredDefinition>()\n\n constructor(readonly evaluator: EvaluatorIdentity) {\n nonEmpty(evaluator.name, 'evaluator.name')\n nonEmpty(evaluator.version, 'evaluator.version')\n }\n\n register(definition: ProtocolDefinition): () => void {\n validateDefinition(definition)\n const accepted = new Set([definition.apiVersion, ...(definition.accepts ?? [])])\n for (const version of accepted) {\n const key = protocolKey({ apiVersion: version, kind: definition.kind })\n if (this.definitions.has(key)) {\n throw new Error(`protocol definition for ${version} ${definition.kind} is already registered`)\n }\n }\n const stored = Object.freeze({ definition: freezeDefinition(definition), accepted: new Set(accepted) })\n for (const version of accepted) this.definitions.set(protocolKey({ apiVersion: version, kind: definition.kind }), stored)\n return () => {\n for (const version of accepted) {\n const key = protocolKey({ apiVersion: version, kind: definition.kind })\n if (this.definitions.get(key) === stored) this.definitions.delete(key)\n }\n }\n }\n\n list(): readonly ProtocolDefinition[] {\n return Object.freeze([...new Set([...this.definitions.values()].map(row => row.definition))])\n }\n\n resolve(reference: ApiReference): ProtocolDefinition | undefined {\n validateApiReference(reference)\n return this.definitions.get(protocolKey(reference))?.definition\n }\n\n understands(reference: ApiReference): boolean {\n return this.resolve(reference) !== undefined\n }\n\n negotiate(declarations: readonly ProtocolDeclaration[], policy?: unknown): NegotiationReport {\n const participantIds = new Set<string>()\n for (const declaration of declarations) {\n validateProtocolDeclaration(declaration)\n if (participantIds.has(declaration.participant.id)) {\n throw new TypeError(`duplicate participant identity ${JSON.stringify(declaration.participant.id)}`)\n }\n participantIds.add(declaration.participant.id)\n }\n\n const groups = new Map<StoredDefinition, {\n requirements: ProtocolRequirementEntry[]\n supports: ProtocolSupportEntry[]\n }>()\n const issues: ProtocolIssue[] = []\n for (const [declarationIndex, declaration] of declarations.entries()) {\n for (const [index, requirement] of (declaration.requires ?? []).entries()) {\n const stored = this.definitions.get(protocolKey(requirement))\n if (stored === undefined) {\n issues.push(freezeIssue({\n code: 'definition-unavailable',\n severity: requirement.optional === true ? 'warning' : 'error',\n participant: declaration.participant.id,\n path: `/declarations/${declarationIndex}/requires/${index}`,\n message: `no definition recognizes ${requirement.apiVersion} ${requirement.kind}`,\n }))\n continue\n }\n const group = groups.get(stored) ?? { requirements: [], supports: [] }\n try {\n group.requirements.push(Object.freeze({\n participant: declaration.participant.id,\n requirement: Object.freeze({\n ...requirement,\n ...(Object.hasOwn(requirement, 'spec')\n ? { spec: stored.definition.validateRequirement(requirement.spec) }\n : { spec: stored.definition.validateRequirement(undefined) }),\n }),\n }))\n } catch (error) {\n issues.push(freezeIssue({\n code: 'invalid-requirement', severity: 'error', participant: declaration.participant.id,\n path: `/declarations/${declarationIndex}/requires/${index}/spec`, message: errorMessage(error),\n }))\n }\n groups.set(stored, group)\n }\n for (const [index, support] of (declaration.supports ?? []).entries()) {\n const stored = this.definitions.get(protocolKey(support))\n if (stored === undefined) {\n issues.push(freezeIssue({\n code: 'definition-unavailable', severity: 'warning', participant: declaration.participant.id,\n path: `/declarations/${declarationIndex}/supports/${index}`,\n message: `no definition recognizes ${support.apiVersion} ${support.kind}`,\n }))\n continue\n }\n const group = groups.get(stored) ?? { requirements: [], supports: [] }\n try {\n group.supports.push(Object.freeze({\n participant: declaration.participant.id,\n support: Object.freeze({\n ...support,\n ...(Object.hasOwn(support, 'spec')\n ? { spec: stored.definition.validateSupport(support.spec) }\n : { spec: stored.definition.validateSupport(undefined) }),\n }),\n }))\n } catch (error) {\n issues.push(freezeIssue({\n code: 'invalid-support', severity: 'error', participant: declaration.participant.id,\n path: `/declarations/${declarationIndex}/supports/${index}/spec`, message: errorMessage(error),\n }))\n }\n groups.set(stored, group)\n }\n }\n\n const protocols: NegotiatedProtocol[] = []\n for (const stored of [...groups.keys()].sort((left, right) => protocolKey(left.definition).localeCompare(protocolKey(right.definition)))) {\n const group = groups.get(stored) as NonNullable<ReturnType<typeof groups.get>>\n let outcome: ProtocolNegotiationOutcome\n try {\n outcome = stored.definition.negotiate(Object.freeze({\n requirements: Object.freeze([...group.requirements]),\n supports: Object.freeze([...group.supports]),\n ...(policy === undefined ? {} : { policy }),\n }))\n } catch (error) {\n outcome = { issues: [{ code: 'definition-failed', severity: 'error', message: errorMessage(error) }] }\n }\n const protocolIssues = Object.freeze((outcome.issues ?? []).map(freezeIssue))\n issues.push(...protocolIssues)\n protocols.push(Object.freeze({\n apiVersion: stored.definition.apiVersion,\n kind: stored.definition.kind,\n participants: Object.freeze([...new Set([\n ...group.requirements.map(row => row.participant),\n ...group.supports.map(row => row.participant),\n ])].sort()),\n ...(Object.hasOwn(outcome, 'agreement') ? { agreement: outcome.agreement } : {}),\n issues: protocolIssues,\n }))\n }\n\n return Object.freeze({\n apiVersion: 'core.dsh/report/v1alpha1',\n evaluator: Object.freeze({ ...this.evaluator }),\n compatible: !issues.some(issue => issue.severity === 'error'),\n protocols: Object.freeze(protocols),\n issues: Object.freeze(issues),\n })\n }\n}\n\nfunction validateDefinition(definition: ProtocolDefinition): void {\n validateApiReference(definition, 'protocol definition')\n if (typeof definition.validateRequirement !== 'function'\n || typeof definition.validateSupport !== 'function'\n || typeof definition.negotiate !== 'function') {\n throw new TypeError('protocol definition must provide validators and negotiate')\n }\n const versions = [definition.apiVersion, ...(definition.accepts ?? [])]\n if (new Set(versions).size !== versions.length) throw new TypeError('protocol definition accepts duplicate versions')\n for (const version of versions) validateApiReference({ apiVersion: version, kind: definition.kind })\n}\n\nfunction freezeDefinition(definition: ProtocolDefinition): ProtocolDefinition {\n return Object.freeze({ ...definition, ...(definition.accepts === undefined ? {} : { accepts: Object.freeze([...definition.accepts]) }) })\n}\n\nfunction freezeIssue(issue: ProtocolIssue): ProtocolIssue {\n if (issue.severity !== 'error' && issue.severity !== 'warning') throw new TypeError('protocol issue severity is invalid')\n nonEmpty(issue.code, 'protocol issue.code')\n nonEmpty(issue.message, 'protocol issue.message')\n return Object.freeze({ ...issue })\n}\n\nfunction nonEmpty(value: unknown, label: string): asserts value is string {\n if (typeof value !== 'string' || value.trim() === '') throw new TypeError(`${label} must be a non-empty string`)\n}\n\nfunction errorMessage(error: unknown): string {\n return error instanceof Error ? error.message : String(error)\n}\n","export interface SemanticVersion {\n readonly major: number\n readonly minor: number\n readonly patch: number\n readonly prerelease: readonly (string | number)[]\n readonly build: readonly string[]\n}\n\nexport type VersionRange = string | readonly string[]\n\nexport function parseSemanticVersion(value: string): SemanticVersion {\n const match = /^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-([0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*))?(?:\\+([0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*))?$/u.exec(value)\n if (match === null) throw new TypeError(`invalid semantic version ${JSON.stringify(value)}`)\n const prerelease = match[4] === undefined ? [] : match[4].split('.').map(identifier => {\n if (!/^\\d+$/u.test(identifier)) return identifier\n if (identifier.length > 1 && identifier.startsWith('0')) throw new TypeError(`invalid semantic version ${JSON.stringify(value)}`)\n return Number(identifier)\n })\n return Object.freeze({\n major: Number(match[1]), minor: Number(match[2]), patch: Number(match[3]),\n prerelease: Object.freeze(prerelease),\n build: Object.freeze(match[5] === undefined ? [] : match[5].split('.')),\n })\n}\n\nexport function compareSemanticVersions(leftValue: string | SemanticVersion, rightValue: string | SemanticVersion): number {\n const left = typeof leftValue === 'string' ? parseSemanticVersion(leftValue) : leftValue\n const right = typeof rightValue === 'string' ? parseSemanticVersion(rightValue) : rightValue\n return left.major - right.major\n || left.minor - right.minor\n || left.patch - right.patch\n || comparePrerelease(left.prerelease, right.prerelease)\n}\n\nexport function assertVersionRange(range: VersionRange): void {\n compileRange(range)\n}\n\nexport function satisfiesVersionRange(versionValue: string, range: VersionRange): boolean {\n const version = parseSemanticVersion(versionValue)\n return compileRange(range).some(group => {\n if (version.prerelease.length > 0 && !group.explicitPrereleases.has(coreKey(version))) return false\n return group.predicates.every(predicate => predicate(version))\n })\n}\n\ninterface ComparatorGroup {\n readonly predicates: readonly ((version: SemanticVersion) => boolean)[]\n readonly explicitPrereleases: ReadonlySet<string>\n}\n\nfunction compileRange(range: VersionRange): readonly ComparatorGroup[] {\n const values = typeof range === 'string' ? [range] : range\n if (!Array.isArray(values) || values.length === 0) throw new TypeError('version range must be a string or non-empty array')\n return Object.freeze(values.flatMap(value => {\n if (typeof value !== 'string' || value.trim() === '') throw new TypeError('version range must not be empty')\n return value.split('||').map(part => compileGroup(part.trim()))\n }))\n}\n\nfunction compileGroup(value: string): ComparatorGroup {\n if (value === '') throw new TypeError('version range contains an empty alternative')\n if (value === '*' || /^x$/iu.test(value)) return { predicates: [], explicitPrereleases: new Set() }\n const predicates: Array<(version: SemanticVersion) => boolean> = []\n const explicitPrereleases = new Set<string>()\n for (const token of value.split(/\\s+/u)) {\n const parsed = compileComparator(token)\n predicates.push(...parsed.predicates)\n if (parsed.explicitPrerelease !== undefined) explicitPrereleases.add(parsed.explicitPrerelease)\n }\n return Object.freeze({ predicates: Object.freeze(predicates), explicitPrereleases })\n}\n\nfunction compileComparator(token: string): {\n readonly predicates: readonly ((version: SemanticVersion) => boolean)[]\n readonly explicitPrerelease?: string\n} {\n const match = /^(<=|>=|<|>|=|\\^|~)?(.+)$/u.exec(token)\n if (match === null) throw new TypeError(`invalid version comparator ${JSON.stringify(token)}`)\n const operator = match[1] ?? '='\n const body = match[2] as string\n const partial = /^(0|[1-9]\\d*|[xX*])(?:\\.(0|[1-9]\\d*|[xX*]))?(?:\\.(0|[1-9]\\d*|[xX*]))?$/u.exec(body)\n if (partial !== null && (partial[2] === undefined || partial[3] === undefined || [partial[1], partial[2], partial[3]].some(wild))) {\n if (operator !== '=') {\n if ((operator === '~' || operator === '^') && ![partial[1], partial[2]].some(wild)) {\n const lower = version(Number(partial[1]), Number(partial[2]), partial[3] === undefined || wild(partial[3]) ? 0 : Number(partial[3]))\n return bounded(lower, operator === '~' ? version(lower.major, lower.minor + 1, 0) : caretUpper(lower))\n }\n throw new TypeError(`partial version cannot use ${JSON.stringify(operator)}`)\n }\n return wildcardRange(partial)\n }\n\n const target = parseSemanticVersion(body)\n const explicitPrerelease = target.prerelease.length === 0 ? undefined : coreKey(target)\n if (operator === '^') return { ...bounded(target, caretUpper(target)), ...(explicitPrerelease === undefined ? {} : { explicitPrerelease }) }\n if (operator === '~') return { ...bounded(target, version(target.major, target.minor + 1, 0)), ...(explicitPrerelease === undefined ? {} : { explicitPrerelease }) }\n const comparison = (candidate: SemanticVersion) => compareSemanticVersions(candidate, target)\n const predicate = operator === '=' ? (candidate: SemanticVersion) => comparison(candidate) === 0\n : operator === '<' ? (candidate: SemanticVersion) => comparison(candidate) < 0\n : operator === '<=' ? (candidate: SemanticVersion) => comparison(candidate) <= 0\n : operator === '>' ? (candidate: SemanticVersion) => comparison(candidate) > 0\n : (candidate: SemanticVersion) => comparison(candidate) >= 0\n return { predicates: [predicate], ...(explicitPrerelease === undefined ? {} : { explicitPrerelease }) }\n}\n\nfunction wildcardRange(match: RegExpExecArray): { readonly predicates: readonly ((version: SemanticVersion) => boolean)[] } {\n if (wild(match[1])) return { predicates: [] }\n const major = Number(match[1])\n if (match[2] === undefined || wild(match[2])) return bounded(version(major, 0, 0), version(major + 1, 0, 0))\n const minor = Number(match[2])\n if (match[3] === undefined || wild(match[3])) return bounded(version(major, minor, 0), version(major, minor + 1, 0))\n throw new TypeError('unreachable complete version range')\n}\n\nfunction bounded(lower: SemanticVersion, upper: SemanticVersion): { readonly predicates: readonly ((version: SemanticVersion) => boolean)[] } {\n return { predicates: [\n candidate => compareSemanticVersions(candidate, lower) >= 0,\n candidate => compareSemanticVersions(candidate, upper) < 0,\n ] }\n}\n\nfunction caretUpper(lower: SemanticVersion): SemanticVersion {\n if (lower.major > 0) return version(lower.major + 1, 0, 0)\n if (lower.minor > 0) return version(0, lower.minor + 1, 0)\n return version(0, 0, lower.patch + 1)\n}\n\nfunction version(major: number, minor: number, patch: number): SemanticVersion {\n return { major, minor, patch, prerelease: [], build: [] }\n}\n\nfunction wild(value: string | undefined): boolean {\n return value === '*' || /^x$/iu.test(value ?? '')\n}\n\nfunction coreKey(value: SemanticVersion): string {\n return `${value.major}.${value.minor}.${value.patch}`\n}\n\nfunction comparePrerelease(left: readonly (string | number)[], right: readonly (string | number)[]): number {\n if (left.length === 0) return right.length === 0 ? 0 : 1\n if (right.length === 0) return -1\n for (let index = 0; index < Math.max(left.length, right.length); index += 1) {\n const leftPart = left[index]\n const rightPart = right[index]\n if (leftPart === undefined) return -1\n if (rightPart === undefined) return 1\n if (leftPart === rightPart) continue\n if (typeof leftPart === 'number' && typeof rightPart === 'string') return -1\n if (typeof leftPart === 'string' && typeof rightPart === 'number') return 1\n return leftPart < rightPart ? -1 : 1\n }\n return 0\n}\n"],"mappings":";AAkCA,SAAgB,YAAY,WAAiC;CAC3D,OAAO,GAAG,UAAU,WAAW,IAAI,UAAU;AAC/C;;AAGA,SAAgB,kBAAkB,WAAiC;CACjE,MAAM,UAAU,gBAAgB,UAAU,UAAU;CACpD,OAAO,GAAG,QAAQ,MAAM,IAAI,Q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E;AAClD;AAEA,SAAS,QAAQ,OAAgC;CAC/C,OAAO,GAAG,MAAM,MAAM,GAAG,MAAM,MAAM,GAAG,MAAM;AAChD;AAEA,SAAS,kBAAkB,MAAoC,OAA6C;CAC1G,IAAI,KAAK,WAAW,GAAG,OAAO,MAAM,WAAW,IAAI,IAAI;CACvD,IAAI,MAAM,WAAW,GAAG,OAAO;CAC/B,KAAK,IAAI,QAAQ,GAAG,QAAQ,KAAK,IAAI,KAAK,QAAQ,MAAM,MAAM,GAAG,SAAS,GAAG;EAC3E,MAAM,WAAW,KAAK;EACtB,MAAM,YAAY,MAAM;EACxB,IAAI,aAAa,KAAA,GAAW,OAAO;EACnC,IAAI,cAAc,KAAA,GAAW,OAAO;EACpC,IAAI,aAAa,WAAW;EAC5B,IAAI,OAAO,aAAa,YAAY,OAAO,cAAc,UAAU,OAAO;EAC1E,IAAI,OAAO,aAAa,YAAY,OAAO,cAAc,UAAU,OAAO;EAC1E,OAAO,WAAW,YAAY,KAAK;CACrC;CACA,OAAO;AACT"}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@dsh-std/core",
|
|
3
|
-
"version": "0.1.0",
|
|
4
|
-
"license": "MIT",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"main": "lib/index.js",
|
|
7
|
-
"types": "lib/index.d.ts",
|
|
8
|
-
"exports": {
|
|
9
|
-
".": {
|
|
10
|
-
"types": "./lib/index.d.ts",
|
|
11
|
-
"default": "./lib/index.js"
|
|
12
|
-
}
|
|
13
|
-
},
|
|
14
|
-
"files": ["lib", "CHANGELOG.md"],
|
|
15
|
-
"scripts": {
|
|
16
|
-
"build": "pnpm run typecheck && tsdown",
|
|
17
|
-
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
18
|
-
"test": "vitest run"
|
|
19
|
-
},
|
|
20
|
-
"engines": { "node": "^22.19 || >=24" }
|
|
21
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@dsh-std/core",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "lib/index.js",
|
|
7
|
+
"types": "lib/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./lib/index.d.ts",
|
|
11
|
+
"default": "./lib/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": ["lib", "CHANGELOG.md"],
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "pnpm run typecheck && tsdown",
|
|
17
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
18
|
+
"test": "vitest run"
|
|
19
|
+
},
|
|
20
|
+
"engines": { "node": "^22.19 || >=24" }
|
|
21
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
Changes to `@dsh-std/manifest` are recorded here.
|
|
4
|
-
|
|
5
|
-
## 0.1.0 (draft)
|
|
6
|
-
|
|
7
|
-
- Added Community v0.15 manifest parsing and validation.
|
|
8
|
-
- Added definition catalogs for independently installed extension protocols.
|
|
9
|
-
- Kept activation, compatibility, and runtime availability separate from manifest validity.
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
Changes to `@dsh-std/manifest` are recorded here.
|
|
4
|
+
|
|
5
|
+
## 0.1.0 (draft)
|
|
6
|
+
|
|
7
|
+
- Added Community v0.15 manifest parsing and validation.
|
|
8
|
+
- Added definition catalogs for independently installed extension protocols.
|
|
9
|
+
- Kept activation, compatibility, and runtime availability separate from manifest validity.
|