@alvin0/ai-agent-sdk-core 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (178) hide show
  1. package/dist/agent/define/session/model-config.js +1 -1
  2. package/dist/agent/define/session/model-config.js.map +1 -1
  3. package/dist/agent/define/session/types.d.ts +21 -0
  4. package/dist/agent/define/session/types.d.ts.map +1 -1
  5. package/dist/agent/define/session.d.ts +2 -0
  6. package/dist/agent/define/session.d.ts.map +1 -1
  7. package/dist/agent/define/session.js +1 -1
  8. package/dist/agent/define/session.js.map +1 -1
  9. package/dist/agent/history/validation.js +1 -1
  10. package/dist/agent/history/validation.js.map +1 -1
  11. package/dist/agent/loop/events.d.ts +5 -0
  12. package/dist/agent/loop/events.d.ts.map +1 -1
  13. package/dist/agent/loop/schedule.js +1 -1
  14. package/dist/agent/loop/schedule.js.map +1 -1
  15. package/dist/agent/loop/turn/model-round.js +1 -1
  16. package/dist/agent/loop/turn/model-round.js.map +1 -1
  17. package/dist/agent/loop/turn/types.d.ts +2 -0
  18. package/dist/agent/loop/turn/types.d.ts.map +1 -1
  19. package/dist/agent/loop/turn/validation.js +1 -1
  20. package/dist/agent/loop/turn/validation.js.map +1 -1
  21. package/dist/agent/memory/compaction.d.ts +10 -1
  22. package/dist/agent/memory/compaction.d.ts.map +1 -1
  23. package/dist/agent/memory/compaction.js +2 -2
  24. package/dist/agent/memory/compaction.js.map +1 -1
  25. package/dist/agent/memory/token-estimator.js +1 -1
  26. package/dist/agent/memory/token-estimator.js.map +1 -1
  27. package/dist/agent/mode/run-agent.js +1 -1
  28. package/dist/agent/mode/run-agent.js.map +1 -1
  29. package/dist/composition/agent/options.js +1 -1
  30. package/dist/composition/agent/options.js.map +1 -1
  31. package/dist/composition/agent/session.js +1 -1
  32. package/dist/composition/agent/session.js.map +1 -1
  33. package/dist/composition/agent/types.d.ts +43 -1
  34. package/dist/composition/agent/types.d.ts.map +1 -1
  35. package/dist/composition/common/errors.d.ts.map +1 -1
  36. package/dist/composition/common/errors.js +1 -1
  37. package/dist/composition/common/errors.js.map +1 -1
  38. package/dist/composition/embedding/activation.js +2 -0
  39. package/dist/composition/embedding/activation.js.map +1 -0
  40. package/dist/composition/embedding/cache.js +2 -0
  41. package/dist/composition/embedding/cache.js.map +1 -0
  42. package/dist/composition/embedding/definition.d.ts +7 -0
  43. package/dist/composition/embedding/definition.d.ts.map +1 -0
  44. package/dist/composition/embedding/definition.js +2 -0
  45. package/dist/composition/embedding/definition.js.map +1 -0
  46. package/dist/composition/embedding/handle.js +2 -0
  47. package/dist/composition/embedding/handle.js.map +1 -0
  48. package/dist/composition/embedding/limiter.js +2 -0
  49. package/dist/composition/embedding/limiter.js.map +1 -0
  50. package/dist/composition/embedding/manager.js +2 -0
  51. package/dist/composition/embedding/manager.js.map +1 -0
  52. package/dist/composition/embedding/observation.js +2 -0
  53. package/dist/composition/embedding/observation.js.map +1 -0
  54. package/dist/composition/embedding/planner.js +2 -0
  55. package/dist/composition/embedding/planner.js.map +1 -0
  56. package/dist/composition/embedding/plugin-types.d.ts +48 -0
  57. package/dist/composition/embedding/plugin-types.d.ts.map +1 -0
  58. package/dist/composition/embedding/plugin-types.js +2 -0
  59. package/dist/composition/embedding/plugin-types.js.map +1 -0
  60. package/dist/composition/embedding/preflight.js +2 -0
  61. package/dist/composition/embedding/preflight.js.map +1 -0
  62. package/dist/composition/embedding/registry.js +2 -0
  63. package/dist/composition/embedding/registry.js.map +1 -0
  64. package/dist/composition/embedding/retry.js +2 -0
  65. package/dist/composition/embedding/retry.js.map +1 -0
  66. package/dist/composition/embedding/usage.js +2 -0
  67. package/dist/composition/embedding/usage.js.map +1 -0
  68. package/dist/composition/lifecycle/types.d.ts +5 -1
  69. package/dist/composition/lifecycle/types.d.ts.map +1 -1
  70. package/dist/composition/lifecycle/types.js +1 -1
  71. package/dist/composition/lifecycle/types.js.map +1 -1
  72. package/dist/composition/preflight.js +1 -1
  73. package/dist/composition/preflight.js.map +1 -1
  74. package/dist/composition/provider/activation.js +1 -1
  75. package/dist/composition/provider/activation.js.map +1 -1
  76. package/dist/composition/provider/model-selection.js +1 -1
  77. package/dist/composition/provider/model-selection.js.map +1 -1
  78. package/dist/composition/provider/preflight.js +1 -1
  79. package/dist/composition/provider/preflight.js.map +1 -1
  80. package/dist/composition/runtime/owner.js +1 -1
  81. package/dist/composition/runtime/owner.js.map +1 -1
  82. package/dist/composition/runtime/public.js +1 -1
  83. package/dist/composition/runtime/public.js.map +1 -1
  84. package/dist/composition/runtime/types.d.ts +25 -2
  85. package/dist/composition/runtime/types.d.ts.map +1 -1
  86. package/dist/composition/startup.js +1 -1
  87. package/dist/composition/startup.js.map +1 -1
  88. package/dist/composition/team/options.js +1 -1
  89. package/dist/composition/team/options.js.map +1 -1
  90. package/dist/composition/team/runtime.js +1 -1
  91. package/dist/composition/team/runtime.js.map +1 -1
  92. package/dist/composition/team/types.d.ts +3 -0
  93. package/dist/composition/team/types.d.ts.map +1 -1
  94. package/dist/contract/generate-options.d.ts +2 -0
  95. package/dist/contract/generate-options.d.ts.map +1 -1
  96. package/dist/contract/model-info.d.ts +12 -2
  97. package/dist/contract/model-info.d.ts.map +1 -1
  98. package/dist/embedding/adapter.d.ts +104 -0
  99. package/dist/embedding/adapter.d.ts.map +1 -0
  100. package/dist/embedding/adapter.js +2 -0
  101. package/dist/embedding/adapter.js.map +1 -0
  102. package/dist/embedding/catalog.d.ts +82 -0
  103. package/dist/embedding/catalog.d.ts.map +1 -0
  104. package/dist/embedding/catalog.js +2 -0
  105. package/dist/embedding/catalog.js.map +1 -0
  106. package/dist/embedding/errors.d.ts +98 -0
  107. package/dist/embedding/errors.d.ts.map +1 -0
  108. package/dist/embedding/errors.js +2 -0
  109. package/dist/embedding/errors.js.map +1 -0
  110. package/dist/embedding/handle.d.ts +76 -0
  111. package/dist/embedding/handle.d.ts.map +1 -0
  112. package/dist/embedding/limits.d.ts +47 -0
  113. package/dist/embedding/limits.d.ts.map +1 -0
  114. package/dist/embedding/limits.js +2 -0
  115. package/dist/embedding/limits.js.map +1 -0
  116. package/dist/embedding/profile.d.ts +89 -0
  117. package/dist/embedding/profile.d.ts.map +1 -0
  118. package/dist/embedding/profile.js +2 -0
  119. package/dist/embedding/profile.js.map +1 -0
  120. package/dist/embedding/purpose.d.ts +37 -0
  121. package/dist/embedding/purpose.d.ts.map +1 -0
  122. package/dist/embedding/request.d.ts +54 -0
  123. package/dist/embedding/request.d.ts.map +1 -0
  124. package/dist/embedding/request.js +2 -0
  125. package/dist/embedding/request.js.map +1 -0
  126. package/dist/embedding/result.d.ts +50 -0
  127. package/dist/embedding/result.d.ts.map +1 -0
  128. package/dist/embedding/usage.d.ts +64 -0
  129. package/dist/embedding/usage.d.ts.map +1 -0
  130. package/dist/embedding/usage.js +2 -0
  131. package/dist/embedding/usage.js.map +1 -0
  132. package/dist/embedding/validation.d.ts +68 -0
  133. package/dist/embedding/validation.d.ts.map +1 -0
  134. package/dist/embedding/validation.js +2 -0
  135. package/dist/embedding/validation.js.map +1 -0
  136. package/dist/embedding.d.ts +12 -0
  137. package/dist/embedding.js +1 -0
  138. package/dist/index.d.ts +6 -3
  139. package/dist/index.js +1 -1
  140. package/dist/message/content.d.ts +71 -1
  141. package/dist/message/content.d.ts.map +1 -1
  142. package/dist/message/projection.d.ts +28 -2
  143. package/dist/message/projection.d.ts.map +1 -1
  144. package/dist/message/projection.js +1 -1
  145. package/dist/message/projection.js.map +1 -1
  146. package/dist/observability/bus.js +1 -1
  147. package/dist/observation/event.d.ts +1 -1
  148. package/dist/observation/event.d.ts.map +1 -1
  149. package/dist/observation/event.js.map +1 -1
  150. package/dist/observation/port.d.ts +1 -1
  151. package/dist/observation/port.d.ts.map +1 -1
  152. package/dist/observation/port.js.map +1 -1
  153. package/dist/observation/privacy.js +1 -1
  154. package/dist/observation/privacy.js.map +1 -1
  155. package/dist/observation/report.d.ts +2 -0
  156. package/dist/observation/report.d.ts.map +1 -1
  157. package/dist/observation/report.js.map +1 -1
  158. package/dist/primitives/version.d.ts +1 -1
  159. package/dist/primitives/version.js +1 -1
  160. package/dist/primitives/version.js.map +1 -1
  161. package/dist/provider.d.ts +3 -1
  162. package/dist/provider.js +1 -1
  163. package/dist/runtime/model-call-handle.js +1 -1
  164. package/dist/runtime/model-call-handle.js.map +1 -1
  165. package/dist/runtime/model-metadata.js +1 -1
  166. package/dist/runtime/model-metadata.js.map +1 -1
  167. package/dist/runtime/model-stream.js +1 -1
  168. package/dist/runtime/model-stream.js.map +1 -1
  169. package/dist/runtime/registry.js +1 -1
  170. package/dist/runtime/with-retry.d.ts.map +1 -1
  171. package/dist/runtime/with-retry.js +1 -1
  172. package/dist/runtime/with-retry.js.map +1 -1
  173. package/dist/stream/assembler.d.ts.map +1 -1
  174. package/dist/stream/assembler.js +1 -1
  175. package/dist/stream/assembler.js.map +1 -1
  176. package/dist/stream/chunk.d.ts +6 -0
  177. package/dist/stream/chunk.d.ts.map +1 -1
  178. package/package.json +6 -1
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.js","names":[],"sources":["../../../src/composition/team/runtime.ts"],"sourcesContent":["import { AgentTeam } from '../../agent/team/team.ts'\nimport type { AgentSessionTeamPort, AgentSessionTeamAttachmentOptions } from '../../agent/define/session/types.ts'\nimport type {\n AgentTeamEvent, LinkAgentOptions, LinkedAgentResult, LinkedAgentSendInput,\n SendAgentMessageRequest, SendAgentMessageResult,\n} from '../../agent/team/types.ts'\nimport { memberName } from '../../agent/team/common.ts'\nimport { AgentSdkError } from '../../errors/agent-sdk-error.ts'\nimport { NOT_APPLICABLE_USAGE_COVERAGE } from '../../support-safe/error.ts'\nimport { atDeadline, BoundaryFailure } from '../lifecycle/bounded.ts'\nimport type { RuntimeAgentHost } from '../agent/session.ts'\nimport { createRuntimeTeamMemberSession, preflightRuntimeTeamMember } from '../agent/session.ts'\nimport { captureInvocationOptions } from '../agent/options.ts'\nimport { boundedText, capturedMethod, objectValue, optionalAbortSignal, ownData } from '../common/data.ts'\nimport { COMPOSITION_LIMITS } from '../common/config.ts'\nimport { captureCloseSignal } from '../runtime/config.ts'\nimport { captureRuntimeTeamOptions } from './options.ts'\nimport { RUNTIME_TEAM_ERROR_CODES, RUNTIME_TEAM_LIMITS } from './config.ts'\nimport { TEAM_TOOL_NAMES } from '../../agent/team/common.ts'\nimport type {\n RuntimeAgentTeam, RuntimeAgentTeamEvent, RuntimeTeamRegistration,\n} from './types.ts'\nimport type { RuntimeAgentInvocationOptions } from '../agent/types.ts'\nimport type { RuntimeAgentSession } from '../agent/types.ts'\nimport type { TeamSessionPort } from '../../agent/team/contracts.ts'\n\nclass RuntimeTeamValue implements RuntimeTeamRegistration {\n readonly id: string\n readonly view: RuntimeAgentTeam\n private closing: Promise<void> | undefined\n private draining: Promise<void> | undefined\n private closed = false\n private readonly activeRuns = new Set<Promise<void>>()\n\n constructor(\n private readonly host: RuntimeAgentHost,\n private readonly team: AgentTeam,\n private readonly sessions: Map<string, RuntimeAgentSession>,\n memberNames: readonly string[],\n private readonly onClosed: (registration: RuntimeTeamRegistration) => void,\n private readonly lifecycle: AbortController,\n ) {\n this.id = team.id\n this.view = Object.freeze({\n id: team.id, memberNames,\n linkAgent: (options: LinkAgentOptions) => this.linkAgent(options),\n sendMessage: (request: SendAgentMessageRequest) => this.sendMessage(request),\n session: (name: string) => this.session(name),\n run: (name: string, input: string, options?: RuntimeAgentInvocationOptions) => this.run(name, input, options),\n close: (options?: { readonly signal?: AbortSignal }) => this.close(options),\n })\n }\n\n private assertActive(): void {\n this.host.operations.assertActive()\n if (this.closed) throw new AgentSdkError('Runtime team is closed', RUNTIME_TEAM_ERROR_CODES.closed)\n }\n\n private session(name: string) {\n this.assertActive()\n const value = this.sessions.get(memberName(name))\n if (value === undefined) throw new AgentSdkError('Runtime team member is unavailable', RUNTIME_TEAM_ERROR_CODES.invalid)\n return value\n }\n\n private run(name: string, input: string, rawOptions?: Parameters<RuntimeAgentTeam['run']>[2]) {\n this.assertActive()\n if (typeof input !== 'string') throw new TypeError('Runtime team input must be a string')\n const options = captureInvocationOptions(rawOptions)\n const session = this.session(name)\n const signal = options.signal === undefined\n ? this.lifecycle.signal\n : AbortSignal.any([options.signal, this.lifecycle.signal])\n const running = this.host.operations.execute('team-operation', {\n signal,\n }, lease => session.run(input, { ...options, signal: lease.signal }))\n const settled = running.then(() => undefined, () => undefined)\n this.activeRuns.add(settled)\n void settled.finally(() => this.activeRuns.delete(settled))\n return running\n }\n\n private sendMessage(raw: SendAgentMessageRequest): Promise<SendAgentMessageResult> {\n this.assertActive()\n const request = captureMessage(raw)\n return this.host.operations.execute('team-operation', {\n ...(request.signal === undefined ? {} : { signal: request.signal }),\n }, lease => this.team.sendMessage({ ...request, signal: lease.signal }))\n }\n\n private linkAgent(raw: LinkAgentOptions): () => void {\n this.assertActive()\n const options = captureLink(raw, this.host, this.team.id)\n const unlink = this.team.linkAgent(options)\n let active = true\n return () => {\n if (!active) return\n unlink()\n active = false\n }\n }\n\n private close(raw?: { readonly signal?: AbortSignal }): Promise<void> {\n if (this.closing !== undefined) return this.closing\n const signal = captureCloseSignal(raw)\n let resolve!: () => void\n let reject!: (error: unknown) => void\n this.closing = new Promise<void>((done, fail) => { resolve = done; reject = fail })\n const shared = this.closing\n void shared.catch(() => undefined)\n this.closed = true\n try {\n this.lifecycle.abort(new Error('Runtime agent team is closing'))\n const runs = [...this.activeRuns]\n const sessions = [...this.sessions.values()]\n const draining = Promise.all([\n this.team.dispose(new Error('Runtime agent team is closing')),\n Promise.all(runs),\n Promise.all(sessions.map(session => session.whenIdle())),\n ]).then(() => undefined).finally(() => {\n // The runtime retains this lightweight registration for close reporting.\n // Member sessions can contain full histories and must not remain reachable\n // from a long-lived runtime after the team has settled.\n this.sessions.clear()\n })\n this.draining = draining\n void draining.then(() => this.onClosed(this), () => undefined)\n void atDeadline(\n this.host.resources, this.host.resources.platform.monotonicNow() + RUNTIME_TEAM_LIMITS.closeTimeoutMs,\n () => draining, signal,\n ).then(resolve, error => {\n const aborted = error instanceof BoundaryFailure && error.reason === 'aborted'\n reject(new AgentSdkError(\n aborted ? 'Runtime team close wait was aborted' : 'Runtime team did not close within 30000ms',\n aborted ? 'TEAM_CLOSE_ABORTED' : 'TEAM_DISPOSE_TIMEOUT',\n ))\n })\n } catch (error) { reject(error) }\n return shared\n }\n\n async closeForRuntime(deadlineAt: number) {\n try {\n // Cancellation and disposal must start even when quiescence used the entire deadline.\n this.close()\n await atDeadline(this.host.resources, deadlineAt, () => this.draining)\n return Object.freeze({ kind: 'agent-team' as const, id: this.team.id, status: 'closed' as const })\n } catch {\n return Object.freeze({ kind: 'agent-team' as const, id: this.team.id, status: 'timed-out' as const,\n error: Object.freeze({ code: 'CAPABILITY_CLEANUP_TIMEOUT', stage: 'team-cleanup',\n message: 'Runtime agent team did not close before the shared deadline' }) })\n }\n }\n}\n\nexport function createRuntimeAgentTeam(\n host: RuntimeAgentHost,\n raw: unknown,\n onClosed: (registration: RuntimeTeamRegistration) => void = () => undefined,\n): RuntimeTeamRegistration {\n host.operations.assertActive()\n const options = captureRuntimeTeamOptions(raw)\n for (const member of options.members) {\n preflightRuntimeTeamMember(host, member.agent, member.session,\n member.tools === false ? [] : Object.values(TEAM_TOOL_NAMES))\n }\n const pendingEvents: RuntimeAgentTeamEvent[] = []\n const lifecycle = new AbortController()\n let emit = (event: RuntimeAgentTeamEvent): void => { pendingEvents.push(event) }\n const team = new AgentTeam({ id: options.id, maxMembers: RUNTIME_TEAM_LIMITS.members,\n ...(options.maxMessages === undefined ? {} : { maxMessages: options.maxMessages }),\n ...(options.maxMessageBytes === undefined ? {} : { maxMessageBytes: options.maxMessageBytes }),\n ...(options.operationTimeoutMs === undefined ? {} : { operationTimeoutMs: options.operationTimeoutMs }),\n ...(options.observerTimeoutMs === undefined ? {} : { observerTimeoutMs: options.observerTimeoutMs }),\n onEvent: event => {\n // The composition owns additional direct runs and compactions; its close\n // event must wait for those too, not just the control-plane wake tasks.\n if (event.type !== 'team-disposed') emit(projectEvent(event))\n },\n }, signal => {\n const lease = host.operations.acquire('team-operation', { signal })\n return () => lease.settle()\n })\n const sessions = new Map<string, RuntimeAgentSession>()\n const ports = new Map<string, TeamSessionPort>()\n const attachments: AgentSessionTeamAttachmentOptions[] = []\n const stagingTeam: AgentSessionTeamPort = Object.freeze({\n attach(_session: Parameters<AgentSessionTeamPort['attach']>[0], attachment: AgentSessionTeamAttachmentOptions = {}) {\n attachments.push(attachment)\n },\n toolsFor: (sender: string) => team.toolsFor(sender),\n instructionsFor: (name: string) => team.instructionsFor(name),\n })\n try {\n for (const member of options.members) {\n const created = createRuntimeTeamMemberSession(host, member.agent, member.session, {\n team: stagingTeam, name: member.name, role: member.role,\n ...(member.description === undefined ? {} : { description: member.description }),\n ...(member.instructions === undefined ? {} : { instructions: member.instructions }),\n ...(member.tools === undefined ? {} : { tools: member.tools }),\n }, lifecycle.signal)\n sessions.set(member.name, created.view)\n ports.set(member.name, created.port)\n }\n for (const attachment of attachments) {\n const name = memberName(attachment.name)\n const port = ports.get(name)\n if (port === undefined) throw new Error(`Runtime team session '${name}' was not staged`)\n team.attach(port, attachment)\n }\n } catch (error) {\n lifecycle.abort(new Error('Runtime agent team construction failed'))\n void team.dispose().catch(() => undefined)\n throw error\n }\n emit = event => {\n // Physical transport work can outlive bounded runtime shutdown.\n if (host.operations.status !== 'closed') options.onEvent?.(event)\n }\n for (const event of pendingEvents) emit(event)\n return new RuntimeTeamValue(\n host, team, sessions, Object.freeze([...sessions.keys()]), registration => {\n onClosed(registration)\n try { emit(Object.freeze({ type: 'team-closed', teamId: team.id })) }\n catch { /* Lifecycle observers cannot change cleanup results. */ }\n }, lifecycle,\n )\n}\n\nfunction captureMessage(raw: unknown): SendAgentMessageRequest {\n const source = objectValue(raw)\n const allowed = new Set(['from', 'target', 'message', 'delivery', 'signal'])\n if (Reflect.ownKeys(source).some(key => typeof key !== 'string' || !allowed.has(key))) {\n throw new TypeError('Runtime team message contains unsupported fields')\n }\n const signal = optionalAbortSignal(ownData(source, 'signal', false))\n const delivery = ownData(source, 'delivery', false)\n return Object.freeze({ from: memberName(ownData(source, 'from')), target: memberName(ownData(source, 'target')),\n message: ownData(source, 'message') as SendAgentMessageRequest['message'],\n ...(delivery === undefined ? {} : { delivery: delivery as NonNullable<SendAgentMessageRequest['delivery']> }),\n ...(signal === undefined ? {} : { signal }) })\n}\n\nfunction captureLink(raw: unknown, host: RuntimeAgentHost, teamId: string): LinkAgentOptions {\n const source = objectValue(raw)\n const name = memberName(ownData(source, 'name'))\n const descriptionValue = ownData(source, 'description', false)\n const transport = objectValue(ownData(source, 'transport'))\n const protocol = boundedText(ownData(transport, 'protocol'), COMPOSITION_LIMITS.identityBytes)\n const agentId = boundedText(ownData(transport, 'agentId'), COMPOSITION_LIMITS.identityBytes)\n const send = capturedMethod<[LinkedAgentSendInput], Promise<LinkedAgentResult>>(transport, 'send')\n const logger = host.observation.logger({ scope: 'sdk.team.transport', fields: { teamId, member: name } })\n return Object.freeze({ name,\n ...(descriptionValue === undefined ? {} : {\n description: boundedText(descriptionValue, 8 * 1_024),\n }),\n transport: Object.freeze({ protocol, agentId,\n send: (input: LinkedAgentSendInput) => send({ ...input, logger }) }),\n })\n}\n\nfunction projectEvent(event: AgentTeamEvent): RuntimeAgentTeamEvent {\n if (event.type === 'member-attached') return Object.freeze({ type: event.type, member: event.member.name })\n if (event.type === 'member-linked') return Object.freeze({ type: event.type, member: event.member.name,\n protocol: event.member.protocol ?? 'unknown' })\n if (event.type === 'message-accepted') return Object.freeze({ type: event.type,\n messageId: event.message.id, target: event.message.target })\n if (event.type === 'member-run-start' || event.type === 'member-run-end') return Object.freeze(event)\n if (event.type === 'member-run-error') return Object.freeze({ type: event.type, member: event.member,\n error: Object.freeze({ code: 'TEAM_MEMBER_RUN_FAILED', stage: 'team-operation',\n message: 'Runtime team member operation failed', usageCoverage: NOT_APPLICABLE_USAGE_COVERAGE,\n possiblyBilledAttemptsWithoutUsage: 0 }) })\n if (event.type === 'team-disposed') return Object.freeze({ type: 'team-closed', teamId: event.teamId })\n return Object.freeze({ type: 'member-run-end', member: event.member })\n}\n"],"mappings":"+4BA0BA,IAAM,EAAN,KAA0D,CASrC,KACA,KACA,SAEA,SACA,UAbnB,GACA,KACA,QACA,SACA,OAAiB,GACjB,WAA8B,IAAI,IAElC,YACE,EACA,EACA,EACA,EACA,EACA,EACA,CANiB,KAAA,KAAA,EACA,KAAA,KAAA,EACA,KAAA,SAAA,EAEA,KAAA,SAAA,EACA,KAAA,UAAA,EAEjB,KAAK,GAAK,EAAK,GACf,KAAK,KAAO,OAAO,OAAO,CACxB,GAAI,EAAK,GAAI,cACb,UAAY,GAA8B,KAAK,UAAU,CAAO,EAChE,YAAc,GAAqC,KAAK,YAAY,CAAO,EAC3E,QAAU,GAAiB,KAAK,QAAQ,CAAI,EAC5C,KAAM,EAAc,EAAe,IAA4C,KAAK,IAAI,EAAM,EAAO,CAAO,EAC5G,MAAQ,GAAgD,KAAK,MAAM,CAAO,CAC5E,CAAC,CACH,CAEA,cAA6B,CAE3B,GADA,KAAK,KAAK,WAAW,aAAa,EAC9B,KAAK,OAAQ,MAAM,IAAI,EAAc,yBAA0B,EAAyB,MAAM,CACpG,CAEA,QAAgB,EAAc,CAC5B,KAAK,aAAa,EAClB,IAAM,EAAQ,KAAK,SAAS,IAAI,EAAW,CAAI,CAAC,EAChD,GAAI,IAAU,IAAA,GAAW,MAAM,IAAI,EAAc,qCAAsC,EAAyB,OAAO,EACvH,OAAO,CACT,CAEA,IAAY,EAAc,EAAe,EAAqD,CAE5F,GADA,KAAK,aAAa,EACd,OAAO,GAAU,SAAU,MAAU,UAAU,qCAAqC,EACxF,IAAM,EAAU,EAAyB,CAAU,EAC7C,EAAU,KAAK,QAAQ,CAAI,EAC3B,EAAS,EAAQ,SAAW,IAAA,GAC9B,KAAK,UAAU,OACf,YAAY,IAAI,CAAC,EAAQ,OAAQ,KAAK,UAAU,MAAM,CAAC,EACrD,EAAU,KAAK,KAAK,WAAW,QAAQ,i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AAC,EACzD,EAAM,OAAS,oBAAsB,EAAM,OAAS,iBAAyB,OAAO,OAAO,CAAK,EAChG,EAAM,OAAS,mBAA2B,OAAO,OAAO,CAAE,KAAM,EAAM,KAAM,OAAQ,EAAM,OAC5F,MAAO,OAAO,OAAO,CAAE,KAAM,yBAA0B,MAAO,iBAC5D,QAAS,uCAAwC,cAAe,EAChE,mCAAoC,CAAE,CAAC,CAAE,CAAC,EAC1C,EAAM,OAAS,gBAAwB,OAAO,OAAO,CAAE,KAAM,cAAe,OAAQ,EAAM,MAAO,CAAC,EAC/F,OAAO,OAAO,CAAE,KAAM,iBAAkB,OAAQ,EAAM,MAAO,CAAC,CACvE"}
1
+ {"version":3,"file":"runtime.js","names":[],"sources":["../../../src/composition/team/runtime.ts"],"sourcesContent":["import { AgentTeam } from '../../agent/team/team.ts'\nimport type { AgentSessionTeamPort, AgentSessionTeamAttachmentOptions } from '../../agent/define/session/types.ts'\nimport type {\n AgentTeamEvent, LinkAgentOptions, LinkedAgentResult, LinkedAgentSendInput,\n SendAgentMessageRequest, SendAgentMessageResult,\n} from '../../agent/team/types.ts'\nimport { memberName } from '../../agent/team/common.ts'\nimport { AgentSdkError } from '../../errors/agent-sdk-error.ts'\nimport { NOT_APPLICABLE_USAGE_COVERAGE } from '../../support-safe/error.ts'\nimport { atDeadline, BoundaryFailure } from '../lifecycle/bounded.ts'\nimport type { RuntimeAgentHost } from '../agent/session.ts'\nimport { createRuntimeTeamMemberSession, preflightRuntimeTeamMember } from '../agent/session.ts'\nimport { captureInvocationOptions } from '../agent/options.ts'\nimport { boundedText, capturedMethod, objectValue, optionalAbortSignal, ownData } from '../common/data.ts'\nimport { COMPOSITION_LIMITS } from '../common/config.ts'\nimport { captureCloseSignal } from '../runtime/config.ts'\nimport { captureRuntimeTeamOptions } from './options.ts'\nimport { RUNTIME_TEAM_ERROR_CODES, RUNTIME_TEAM_LIMITS } from './config.ts'\nimport { TEAM_TOOL_NAMES } from '../../agent/team/common.ts'\nimport type {\n RuntimeAgentTeam, RuntimeAgentTeamEvent, RuntimeTeamRegistration,\n} from './types.ts'\nimport type { RuntimeAgentInvocationOptions } from '../agent/types.ts'\nimport type { RuntimeAgentSession } from '../agent/types.ts'\nimport type { TeamSessionPort } from '../../agent/team/contracts.ts'\n\nclass RuntimeTeamValue implements RuntimeTeamRegistration {\n readonly id: string\n readonly view: RuntimeAgentTeam\n private closing: Promise<void> | undefined\n private draining: Promise<void> | undefined\n private closed = false\n private readonly activeRuns = new Set<Promise<void>>()\n\n constructor(\n private readonly host: RuntimeAgentHost,\n private readonly team: AgentTeam,\n private readonly sessions: Map<string, RuntimeAgentSession>,\n memberNames: readonly string[],\n private readonly onClosed: (registration: RuntimeTeamRegistration) => void,\n private readonly lifecycle: AbortController,\n ) {\n this.id = team.id\n this.view = Object.freeze({\n id: team.id, memberNames,\n linkAgent: (options: LinkAgentOptions) => this.linkAgent(options),\n sendMessage: (request: SendAgentMessageRequest) => this.sendMessage(request),\n session: (name: string) => this.session(name),\n run: (name: string, input: string, options?: RuntimeAgentInvocationOptions) => this.run(name, input, options),\n close: (options?: { readonly signal?: AbortSignal }) => this.close(options),\n })\n }\n\n private assertActive(): void {\n this.host.operations.assertActive()\n if (this.closed) throw new AgentSdkError('Runtime team is closed', RUNTIME_TEAM_ERROR_CODES.closed)\n }\n\n private session(name: string) {\n this.assertActive()\n const value = this.sessions.get(memberName(name))\n if (value === undefined) throw new AgentSdkError('Runtime team member is unavailable', RUNTIME_TEAM_ERROR_CODES.invalid)\n return value\n }\n\n private run(name: string, input: string, rawOptions?: Parameters<RuntimeAgentTeam['run']>[2]) {\n this.assertActive()\n if (typeof input !== 'string') throw new TypeError('Runtime team input must be a string')\n const options = captureInvocationOptions(rawOptions)\n const session = this.session(name)\n const signal = options.signal === undefined\n ? this.lifecycle.signal\n : AbortSignal.any([options.signal, this.lifecycle.signal])\n const running = this.host.operations.execute('team-operation', {\n signal,\n }, lease => session.run(input, { ...options, signal: lease.signal }))\n const settled = running.then(() => undefined, () => undefined)\n this.activeRuns.add(settled)\n void settled.finally(() => this.activeRuns.delete(settled))\n return running\n }\n\n private sendMessage(raw: SendAgentMessageRequest): Promise<SendAgentMessageResult> {\n this.assertActive()\n const request = captureMessage(raw)\n return this.host.operations.execute('team-operation', {\n ...(request.signal === undefined ? {} : { signal: request.signal }),\n }, lease => this.team.sendMessage({ ...request, signal: lease.signal }))\n }\n\n private linkAgent(raw: LinkAgentOptions): () => void {\n this.assertActive()\n const options = captureLink(raw, this.host, this.team.id)\n const unlink = this.team.linkAgent(options)\n let active = true\n return () => {\n if (!active) return\n unlink()\n active = false\n }\n }\n\n private close(raw?: { readonly signal?: AbortSignal }): Promise<void> {\n if (this.closing !== undefined) return this.closing\n const signal = captureCloseSignal(raw)\n let resolve!: () => void\n let reject!: (error: unknown) => void\n this.closing = new Promise<void>((done, fail) => { resolve = done; reject = fail })\n const shared = this.closing\n void shared.catch(() => undefined)\n this.closed = true\n try {\n this.lifecycle.abort(new Error('Runtime agent team is closing'))\n const runs = [...this.activeRuns]\n const sessions = [...this.sessions.values()]\n const draining = Promise.all([\n this.team.dispose(new Error('Runtime agent team is closing')),\n Promise.all(runs),\n Promise.all(sessions.map(session => session.whenIdle())),\n ]).then(() => undefined).finally(() => {\n // The runtime retains this lightweight registration for close reporting.\n // Member sessions can contain full histories and must not remain reachable\n // from a long-lived runtime after the team has settled.\n this.sessions.clear()\n })\n this.draining = draining\n void draining.then(() => this.onClosed(this), () => undefined)\n void atDeadline(\n this.host.resources, this.host.resources.platform.monotonicNow() + RUNTIME_TEAM_LIMITS.closeTimeoutMs,\n () => draining, signal,\n ).then(resolve, error => {\n const aborted = error instanceof BoundaryFailure && error.reason === 'aborted'\n reject(new AgentSdkError(\n aborted ? 'Runtime team close wait was aborted' : 'Runtime team did not close within 30000ms',\n aborted ? 'TEAM_CLOSE_ABORTED' : 'TEAM_DISPOSE_TIMEOUT',\n ))\n })\n } catch (error) { reject(error) }\n return shared\n }\n\n async closeForRuntime(deadlineAt: number) {\n try {\n // Cancellation and disposal must start even when quiescence used the entire deadline.\n this.close()\n await atDeadline(this.host.resources, deadlineAt, () => this.draining)\n return Object.freeze({ kind: 'agent-team' as const, id: this.team.id, status: 'closed' as const })\n } catch {\n return Object.freeze({ kind: 'agent-team' as const, id: this.team.id, status: 'timed-out' as const,\n error: Object.freeze({ code: 'CAPABILITY_CLEANUP_TIMEOUT', stage: 'team-cleanup',\n message: 'Runtime agent team did not close before the shared deadline' }) })\n }\n }\n}\n\nexport function createRuntimeAgentTeam(\n host: RuntimeAgentHost,\n raw: unknown,\n onClosed: (registration: RuntimeTeamRegistration) => void = () => undefined,\n): RuntimeTeamRegistration {\n host.operations.assertActive()\n const options = captureRuntimeTeamOptions(raw)\n for (const member of options.members) {\n preflightRuntimeTeamMember(host, member.agent, member.session,\n member.tools === false ? [] : Object.values(TEAM_TOOL_NAMES))\n }\n const pendingEvents: RuntimeAgentTeamEvent[] = []\n const lifecycle = new AbortController()\n let emit = (event: RuntimeAgentTeamEvent): void => { pendingEvents.push(event) }\n const team = new AgentTeam({ id: options.id, maxMembers: RUNTIME_TEAM_LIMITS.members,\n ...(options.maxMessages === undefined ? {} : { maxMessages: options.maxMessages }),\n ...(options.maxMessageBytes === undefined ? {} : { maxMessageBytes: options.maxMessageBytes }),\n ...(options.operationTimeoutMs === undefined ? {} : { operationTimeoutMs: options.operationTimeoutMs }),\n ...(options.observerTimeoutMs === undefined ? {} : { observerTimeoutMs: options.observerTimeoutMs }),\n onEvent: event => {\n // The composition owns additional direct runs and compactions; its close\n // event must wait for those too, not just the control-plane wake tasks.\n if (event.type !== 'team-disposed') emit(projectEvent(event))\n },\n ...(options.onAgentEvent === undefined ? {} : { onAgentEvent: options.onAgentEvent }),\n }, signal => {\n const lease = host.operations.acquire('team-operation', { signal })\n return () => lease.settle()\n })\n const sessions = new Map<string, RuntimeAgentSession>()\n const ports = new Map<string, TeamSessionPort>()\n const attachments: AgentSessionTeamAttachmentOptions[] = []\n const stagingTeam: AgentSessionTeamPort = Object.freeze({\n attach(_session: Parameters<AgentSessionTeamPort['attach']>[0], attachment: AgentSessionTeamAttachmentOptions = {}) {\n attachments.push(attachment)\n },\n toolsFor: (sender: string) => team.toolsFor(sender),\n instructionsFor: (name: string) => team.instructionsFor(name),\n })\n try {\n for (const member of options.members) {\n const created = createRuntimeTeamMemberSession(host, member.agent, member.session, {\n team: stagingTeam, name: member.name, role: member.role,\n ...(member.description === undefined ? {} : { description: member.description }),\n ...(member.instructions === undefined ? {} : { instructions: member.instructions }),\n ...(member.tools === undefined ? {} : { tools: member.tools }),\n }, lifecycle.signal)\n sessions.set(member.name, created.view)\n ports.set(member.name, created.port)\n }\n for (const attachment of attachments) {\n const name = memberName(attachment.name)\n const port = ports.get(name)\n if (port === undefined) throw new Error(`Runtime team session '${name}' was not staged`)\n team.attach(port, attachment)\n }\n } catch (error) {\n lifecycle.abort(new Error('Runtime agent team construction failed'))\n void team.dispose().catch(() => undefined)\n throw error\n }\n emit = event => {\n // Physical transport work can outlive bounded runtime shutdown.\n if (host.operations.status !== 'closed') options.onEvent?.(event)\n }\n for (const event of pendingEvents) emit(event)\n return new RuntimeTeamValue(\n host, team, sessions, Object.freeze([...sessions.keys()]), registration => {\n onClosed(registration)\n try { emit(Object.freeze({ type: 'team-closed', teamId: team.id })) }\n catch { /* Lifecycle observers cannot change cleanup results. */ }\n }, lifecycle,\n )\n}\n\nfunction captureMessage(raw: unknown): SendAgentMessageRequest {\n const source = objectValue(raw)\n const allowed = new Set(['from', 'target', 'message', 'delivery', 'signal'])\n if (Reflect.ownKeys(source).some(key => typeof key !== 'string' || !allowed.has(key))) {\n throw new TypeError('Runtime team message contains unsupported fields')\n }\n const signal = optionalAbortSignal(ownData(source, 'signal', false))\n const delivery = ownData(source, 'delivery', false)\n return Object.freeze({ from: memberName(ownData(source, 'from')), target: memberName(ownData(source, 'target')),\n message: ownData(source, 'message') as SendAgentMessageRequest['message'],\n ...(delivery === undefined ? {} : { delivery: delivery as NonNullable<SendAgentMessageRequest['delivery']> }),\n ...(signal === undefined ? {} : { signal }) })\n}\n\nfunction captureLink(raw: unknown, host: RuntimeAgentHost, teamId: string): LinkAgentOptions {\n const source = objectValue(raw)\n const name = memberName(ownData(source, 'name'))\n const descriptionValue = ownData(source, 'description', false)\n const transport = objectValue(ownData(source, 'transport'))\n const protocol = boundedText(ownData(transport, 'protocol'), COMPOSITION_LIMITS.identityBytes)\n const agentId = boundedText(ownData(transport, 'agentId'), COMPOSITION_LIMITS.identityBytes)\n const send = capturedMethod<[LinkedAgentSendInput], Promise<LinkedAgentResult>>(transport, 'send')\n const logger = host.observation.logger({ scope: 'sdk.team.transport', fields: { teamId, member: name } })\n return Object.freeze({ name,\n ...(descriptionValue === undefined ? {} : {\n description: boundedText(descriptionValue, 8 * 1_024),\n }),\n transport: Object.freeze({ protocol, agentId,\n send: (input: LinkedAgentSendInput) => send({ ...input, logger }) }),\n })\n}\n\nfunction projectEvent(event: AgentTeamEvent): RuntimeAgentTeamEvent {\n if (event.type === 'member-attached') return Object.freeze({ type: event.type, member: event.member.name })\n if (event.type === 'member-linked') return Object.freeze({ type: event.type, member: event.member.name,\n protocol: event.member.protocol ?? 'unknown' })\n if (event.type === 'message-accepted') return Object.freeze({ type: event.type,\n messageId: event.message.id, target: event.message.target })\n if (event.type === 'member-run-start' || event.type === 'member-run-end') return Object.freeze(event)\n if (event.type === 'member-run-error') return Object.freeze({ type: event.type, member: event.member,\n error: Object.freeze({ code: 'TEAM_MEMBER_RUN_FAILED', stage: 'team-operation',\n message: 'Runtime team member operation failed', usageCoverage: NOT_APPLICABLE_USAGE_COVERAGE,\n possiblyBilledAttemptsWithoutUsage: 0 }) })\n if (event.type === 'team-disposed') return Object.freeze({ type: 'team-closed', teamId: event.teamId })\n return Object.freeze({ type: 'member-run-end', member: event.member })\n}\n"],"mappings":"+4BA0BA,IAAM,EAAN,KAA0D,CASrC,KACA,KACA,SAEA,SACA,UAbnB,GACA,KACA,QACA,SACA,OAA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S,mBAA2B,OAAO,OAAO,CAAE,KAAM,EAAM,KAAM,OAAQ,EAAM,OAC5F,MAAO,OAAO,OAAO,CAAE,KAAM,yBAA0B,MAAO,iBAC5D,QAAS,uCAAwC,cAAe,EAChE,mCAAoC,CAAE,CAAC,CAAE,CAAC,EAC1C,EAAM,OAAS,gBAAwB,OAAO,OAAO,CAAE,KAAM,cAAe,OAAQ,EAAM,MAAO,CAAC,EAC/F,OAAO,OAAO,CAAE,KAAM,iBAAkB,OAAQ,EAAM,MAAO,CAAC,CACvE"}
@@ -1,4 +1,5 @@
1
1
  import { SupportSafeError } from "../../support-safe/error.js";
2
+ import { AgentRunEvent } from "../../agent/mode/run-agent.js";
2
3
  import { TeamToolAccess } from "../../agent/team/contracts.js";
3
4
  import { LinkAgentOptions, SendAgentMessageRequest, SendAgentMessageResult } from "../../agent/team/types.js";
4
5
  import { RuntimeAgent, RuntimeAgentInvocationOptions, RuntimeAgentResponse, RuntimeAgentSession, RuntimeAgentSessionOptions } from "../agent/types.js";
@@ -45,6 +46,8 @@ interface RuntimeAgentTeamOptions {
45
46
  readonly operationTimeoutMs?: number;
46
47
  readonly observerTimeoutMs?: number;
47
48
  readonly onEvent?: (event: RuntimeAgentTeamEvent) => void;
49
+ /** Observe raw model, tool and span events from member wake-up runs. */
50
+ readonly onAgentEvent?: (member: string, event: AgentRunEvent) => void | Promise<void>;
48
51
  }
49
52
  interface RuntimeAgentTeam {
50
53
  readonly id: string;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","names":[],"sources":["../../../src/composition/team/types.ts"],"mappings":";;;;;UASiB;WACN;WACA,OAAO;WACP;WACA;WACA;WACA,kBAAkB;WAClB,UAAU;;KAGT;WACG;WAAkC;;WAClC;WAAgC;WAAyB;;WACzD;WAAmC;WAA4B;;WAC/D;WAAmC;;WACnC;WAAiC;;WACjC;WAAmC;WAAyB,OAAO;;WACnE;WAA8B;;UAE5B;WACN;WACA,kBAAkB;WAClB;WACA;WACA;WACA;WACA,WAAW,OAAO;;UAGZ;WACN;WACA;EACT,UAAU,SAAS;EACnB,YAAY,SAAS,0BAA0B,QAAQ;EACvD,QAAQ,eAAe;EACvB,IAAI,cAAc,eAAe,UAAU,gCAAgC,QAAQ;;EAEnF,MAAM;aAAqB,SAAS;MAAgB"}
1
+ {"version":3,"file":"types.d.ts","names":[],"sources":["../../../src/composition/team/types.ts"],"mappings":";;;;;;UAUiB;WACN;WACA,OAAO;WACP;WACA;WACA;WACA,kBAAkB;WAClB,UAAU;;KAGT;WACG;WAAkC;;WAClC;WAAgC;WAAyB;;WACzD;WAAmC;WAA4B;;WAC/D;WAAmC;;WACnC;WAAiC;;WACjC;WAAmC;WAAyB,OAAO;;WACnE;WAA8B;;UAE5B;WACN;WACA,kBAAkB;WAClB;WACA;WACA;WACA;WACA,WAAW,OAAO;;WAElB,gBAAgB,gBAAgB,OAAO,yBAAyB;;UAG1D;WACN;WACA;EACT,UAAU,SAAS;EACnB,YAAY,SAAS,0BAA0B,QAAQ;EACvD,QAAQ,eAAe;EACvB,IAAI,cAAc,eAAe,UAAU,gCAAgC,QAAQ;;EAEnF,MAAM;aAAqB,SAAS;MAAgB"}
@@ -7,6 +7,8 @@ import { ModelOutputFormat } from "./output-format.js";
7
7
  interface GenerateOptions {
8
8
  /** strict rejects known text-only models when request history contains images; project permits lossy conversion. */
9
9
  readonly imagePolicy?: 'strict' | 'project';
10
+ /** strict rejects models that decline document input when history contains documents; project permits lossy conversion. */
11
+ readonly documentPolicy?: 'strict' | 'project';
10
12
  /** Registered provider route, selecting the adapter instance. */
11
13
  provider: string;
12
14
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"generate-options.d.ts","names":[],"sources":["../../src/contract/generate-options.ts"],"mappings":";;;;;;UAYiB;;WAEN;;EAET;;;;;;;;EAQA;;EAEA,kBAAkB;;EAElB,mBAAmB;;EAEnB;;EAEA,iBAAiB;;EAEjB,aAAa;;EAEb,eAAe;EACf;EACA;EACA;;EAEA;EACA,SAAS"}
1
+ {"version":3,"file":"generate-options.d.ts","names":[],"sources":["../../src/contract/generate-options.ts"],"mappings":";;;;;;UAYiB;;WAEN;;WAEA;;EAET;;;;;;;;EAQA;;EAEA,kBAAkB;;EAElB,mBAAmB;;EAEnB;;EAEA,iBAAiB;;EAEjB,aAAa;;EAEb,eAAe;EACf;EACA;EACA;;EAEA;EACA,SAAS"}
@@ -13,6 +13,7 @@ interface ProviderInfo {
13
13
  interface ModelModalityMap {
14
14
  text: 'text';
15
15
  image: 'image';
16
+ document: 'document';
16
17
  }
17
18
  /** Any declared model input modality. */
18
19
  type ModelModality = ModelModalityMap[keyof ModelModalityMap];
@@ -36,7 +37,8 @@ interface ModelInfo {
36
37
  * Accepted request modalities.
37
38
  *
38
39
  * Absent means UNKNOWN; an explicit list that omits a modality is a negative
39
- * capability claim, and the registry acts on it by projecting images to text.
40
+ * capability claim, and the registry acts on it by projecting images and
41
+ * documents to text.
40
42
  */
41
43
  inputModalities?: readonly ModelModality[];
42
44
  /** Modalities this model route may return, directly or through native tools. */
@@ -46,8 +48,16 @@ interface ModelInfo {
46
48
  }
47
49
  /** Provider-owned context capacity for one exact model route. */
48
50
  interface ModelContext {
49
- /** Maximum combined request and response tokens. */
51
+ /** Operating budget for combined request and response tokens. */
50
52
  contextWindow: number;
53
+ /** Known technical ceiling, independent of the operating budget. */
54
+ maxContextWindow?: number;
55
+ /** Provider/model operating default before an explicit override. */
56
+ defaultContextWindow?: number;
57
+ /** Input-token threshold above which long-context pricing may apply. */
58
+ standardPriceInputTokens?: number;
59
+ /** Advisory warning, not a prediction of actual billed token counts. */
60
+ pricingWarning?: 'extended-context-may-cost-more';
51
61
  }
52
62
  /** Display metadata for one adapter-owned reasoning effort. */
53
63
  interface ReasoningEffortInfo {
@@ -1 +1 @@
1
- {"version":3,"file":"model-info.d.ts","names":[],"sources":["../../src/contract/model-info.ts"],"mappings":";;;;;UAWiB;;EAEf;;EAEA;;;UAIe;EACf;EACA;;;KAIU,gBAAgB,uBAAuB;;;;;;;;UASlC;;EAEf;;EAEA;;EAEA;;EAEA;;;;;;;EAOA,2BAA2B;;EAE3B,4BAA4B;;EAE5B,uBAAuB;;;UAIR;;EAEf;;;UAIe;;EAEf,IAAI;;EAEJ;;EAEA;;;UAIe;;EAEf,kBAAkB;;;;;EAKlB,gBAAgB;;;UAID,0BAA0B;;EAEzC,UAAU;;EAEV;;EAEA;;EAEA,YAAY;;KAGF;UAEK;WACN,SAAS;WACT;;UAGM;WACN,UAAU;WACV,OAAO;WACP;WACA,iBAAiB;WACjB;WACA;WACA;WACA,QAAQ"}
1
+ {"version":3,"file":"model-info.d.ts","names":[],"sources":["../../src/contract/model-info.ts"],"mappings":";;;;;UAWiB;;EAEf;;EAEA;;;UAIe;EACf;EACA;EACA;;;KAIU,gBAAgB,uBAAuB;;;;;;;;UASlC;;EAEf;;EAEA;;EAEA;;EAEA;;;;;;;;EAQA,2BAA2B;;EAE3B,4BAA4B;;EAE5B,uBAAuB;;;UAIR;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA;;;UAIe;;EAEf,IAAI;;EAEJ;;EAEA;;;UAIe;;EAEf,kBAAkB;;;;;EAKlB,gBAAgB;;;UAID,0BAA0B;;EAEzC,UAAU;;EAEV;;EAEA;;EAEA,YAAY;;KAGF;UAEK;WACN,SAAS;WACT;;UAGM;WACN,UAAU;WACV,OAAO;WACP;WACA,iBAAiB;WACjB;WACA;WACA;WACA,QAAQ"}
@@ -0,0 +1,104 @@
1
+ import { ModelInvocationContext } from "../observation/report.js";
2
+ import { ProviderInfo } from "../contract/model-info.js";
3
+ import { ResolvedRetryPolicy } from "../contract/retry-policy.js";
4
+ import { EmbeddingProfile, EmbeddingProfileInput, EmbeddingSpaceId } from "./profile.js";
5
+ import { EmbeddingModelInfo, ResolvedEmbeddingModelInfo } from "./catalog.js";
6
+ import { ResolvedEmbeddingBatchLimits } from "./limits.js";
7
+ import { EmbeddingBatchRequest } from "./request.js";
8
+ import { EmbeddingBatchResult } from "./result.js";
9
+ //#region src/embedding/adapter.d.ts
10
+ /** Call configuration handed to {@link EmbeddingAdapter.prepareEmbeddingCall}. */
11
+ interface PrepareEmbeddingOptions extends EmbeddingProfileInput {
12
+ /** Caller overrides on the catalog's declared batch bounds. */
13
+ readonly limits?: Partial<ResolvedEmbeddingBatchLimits>;
14
+ }
15
+ /**
16
+ * One adapter-owned embedding-resolution generation, bound to its dispatch call.
17
+ *
18
+ * The embedding counterpart of `PreparedAdapterCall`. Metadata, profile,
19
+ * `spaceId`, and batch limits all come from the SAME capture as
20
+ * {@link PreparedEmbeddingCall.embedBatch}, so dimensions can never be checked
21
+ * against one configuration while the request goes out through another.
22
+ */
23
+ interface PreparedEmbeddingCall {
24
+ /** Exact model metadata from the SAME generation as {@link embedBatch}. */
25
+ readonly model: ResolvedEmbeddingModelInfo;
26
+ /** The `Embedding_Profile` this generation will actually produce vectors in. */
27
+ readonly profile: EmbeddingProfile;
28
+ /** Canonical space identity derived from {@link profile}. */
29
+ readonly spaceId: EmbeddingSpaceId;
30
+ /** From `embedding/limits.ts`, never from `composition/`. */
31
+ readonly limits: ResolvedEmbeddingBatchLimits;
32
+ /** Dispatch through that generation, without re-reading dynamic connection facts. */
33
+ embedBatch(batch: EmbeddingBatchRequest, context?: ModelInvocationContext): Promise<EmbeddingBatchResult>;
34
+ }
35
+ /**
36
+ * Provider-wire adapter for this SDK's embedding vocabulary.
37
+ *
38
+ * Contract obligations on implementations:
39
+ * - exactly one `Provider_Attempt` per `embedBatch()` call; retry is the runtime's;
40
+ * - honour `batch.signal` promptly;
41
+ * - carry the original input index onto every returned vector;
42
+ * - raise a protocol error when a response breaks the contract, never infer;
43
+ * - include the SDK's attribution headers on every provider request.
44
+ */
45
+ declare abstract class EmbeddingAdapter {
46
+ /**
47
+ * Describe one provider route owned by this adapter.
48
+ * @param provider - a route this instance was registered under.
49
+ * @returns detached display metadata whose `id` MUST equal `provider`.
50
+ */
51
+ providerInfo(provider: string): ProviderInfo;
52
+ /**
53
+ * The retry policy this route owns.
54
+ * @param _provider - a route this instance was registered under.
55
+ * @returns a resolved policy, or `undefined` to accept the runtime defaults.
56
+ */
57
+ providerRetryPolicy(_provider: string): ResolvedRetryPolicy | undefined;
58
+ /**
59
+ * List embedding models this adapter can currently advertise for one route.
60
+ *
61
+ * ADVISORY only: absence from this list must never become a reason to reject a
62
+ * request, because an adapter may accept ids it does not list.
63
+ * @param _provider - one route owned by this adapter.
64
+ * @returns discoverable models, in adapter-preferred order.
65
+ */
66
+ listEmbeddingModels(_provider: string, _signal?: AbortSignal): Promise<readonly EmbeddingModelInfo[]>;
67
+ /**
68
+ * Resolve all metadata available for one exact embedding model.
69
+ *
70
+ * NOT request validation — an unknown id resolves to a minimal all-`unknown`
71
+ * descriptor rather than an error.
72
+ * @param provider - one route owned by this adapter.
73
+ * @param model - exact model id.
74
+ * @param _signal - cancellation; async implementations must settle promptly after abort.
75
+ */
76
+ resolveEmbeddingModel(provider: string, model: string, _signal?: AbortSignal): Promise<ResolvedEmbeddingModelInfo>;
77
+ /**
78
+ * Declare the `Embedding_Profile` for one concrete call configuration.
79
+ *
80
+ * NOT abstract: the default derives a compatibility identity from
81
+ * `${route}:${modelId}` when the catalog declares none, marks normalization
82
+ * `'unknown'`, and applies no post-processing. That is what keeps this class at
83
+ * exactly ONE abstract method. An adapter that owns the provider's real
84
+ * statement about its embedding space MUST override.
85
+ */
86
+ embeddingProfile(model: ResolvedEmbeddingModelInfo, request: EmbeddingProfileInput): EmbeddingProfile;
87
+ /**
88
+ * Bind resolved metadata to the exact configuration generation that will dispatch.
89
+ *
90
+ * Adapters whose connection facts come from mutable configuration MUST override
91
+ * and snapshot those facts here.
92
+ * @returns a frozen single-generation embedding entry point.
93
+ */
94
+ prepareEmbeddingCall(provider: string, model: string, options: PrepareEmbeddingOptions, signal?: AbortSignal, context?: ModelInvocationContext): Promise<PreparedEmbeddingCall>;
95
+ /**
96
+ * Perform EXACTLY ONE physical embedding request. The only required method.
97
+ * @param batch - one `Physical_Batch`, already within the resolved limits.
98
+ * @returns one vector per request item, each carrying its original index.
99
+ */
100
+ abstract embedBatch(batch: EmbeddingBatchRequest, context?: ModelInvocationContext): Promise<EmbeddingBatchResult>;
101
+ }
102
+ //#endregion
103
+ export { EmbeddingAdapter, PrepareEmbeddingOptions, PreparedEmbeddingCall };
104
+ //# sourceMappingURL=adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.d.ts","names":[],"sources":["../../src/embedding/adapter.ts"],"mappings":";;;;;;;;;;UAkCiB,gCAAgC;;WAEtC,SAAS,QAAQ;;;;;;;;;;UAWX;;WAEN,OAAO;;WAEP,SAAS;;WAET,SAAS;;WAET,QAAQ;;EAEjB,WACE,OAAO,uBACP,UAAU,yBACT,QAAQ;;;;;;;;;;;;uBAaS;;;;;;EAMpB,aAAa,mBAAmB;;;;;;EAShC,oBAAoB,oBAAoB;;;;;;;;;EAYxC,oBACE,mBACA,UAAU,cACT,iBAAiB;;;;;;;;;;EAapB,sBACE,kBACA,eACA,UAAU,cACT,QAAQ;;;;;;;;;;EAaX,iBACE,OAAO,4BACP,SAAS,wBACR;;;;;;;;EAWG,qBACJ,kBACA,eACA,SAAS,yBACT,SAAS,aACT,UAAU,yBACT,QAAQ;;;;;;WAmBF,WACP,OAAO,uBACP,UAAU,yBACT,QAAQ"}
@@ -0,0 +1,2 @@
1
+ import{defaultEmbeddingProfile as e,deriveSpaceId as t}from"./profile.js";import{resolveBatchLimits as n}from"./limits.js";import{unknownEmbeddingModel as r}from"./catalog.js";var i=class{providerInfo(e){return{id:e,name:e}}providerRetryPolicy(e){}listEmbeddingModels(e,t){return Promise.resolve([])}resolveEmbeddingModel(e,t,n){return Promise.resolve(r(e,t))}embeddingProfile(t,n){return e(t,n)}async prepareEmbeddingCall(e,r,i,a,o){let s=await this.resolveEmbeddingModel(e,r,a),c=this.embeddingProfile(s,i);return Object.freeze({model:s,profile:c,spaceId:t(c),limits:n(s,i.limits),embedBatch:(e,t=o)=>this.embedBatch(e,t)})}};export{i as EmbeddingAdapter};
2
+ //# sourceMappingURL=adapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.js","names":[],"sources":["../../src/embedding/adapter.ts"],"sourcesContent":["/**\n * The contract an embedding provider backend implements.\n *\n * Shape worth noting: ONE abstract method, deliberately mirroring `ModelAdapter`.\n * Everything else has a working default, so a minimal embedding adapter is a\n * single `embedBatch()` implementation, while a mature one overrides metadata,\n * catalog, profile, and call binding. `embeddingProfile()` in particular is NOT\n * abstract — it delegates to {@link defaultEmbeddingProfile} so that a route with\n * no catalog knowledge still produces a usable profile (DD-13).\n *\n * This class does NOT extend `ModelAdapter`. Generation and embedding share no\n * request vocabulary, and inheriting `stream()` would force every embedding\n * backend to implement a method it cannot honour.\n *\n * As with `ModelAdapter`, every metadata method takes the route key as its first\n * argument rather than reading instance state, so one instance can serve many\n * routes with different endpoints and credentials.\n *\n * @module ai-agent-sdk/core/embedding/adapter\n */\n\nimport type { ModelInvocationContext } from '../observation/report.ts'\nimport type { ProviderInfo } from '../contract/model-info.ts'\nimport type { ResolvedRetryPolicy } from '../contract/retry-policy.ts'\nimport type { EmbeddingModelInfo, ResolvedEmbeddingModelInfo } from './catalog.ts'\nimport { unknownEmbeddingModel } from './catalog.ts'\nimport type { ResolvedEmbeddingBatchLimits } from './limits.ts'\nimport { resolveBatchLimits } from './limits.ts'\nimport type { EmbeddingProfile, EmbeddingProfileInput, EmbeddingSpaceId } from './profile.ts'\nimport { defaultEmbeddingProfile, deriveSpaceId } from './profile.ts'\nimport type { EmbeddingBatchRequest } from './request.ts'\nimport type { EmbeddingBatchResult } from './result.ts'\n\n/** Call configuration handed to {@link EmbeddingAdapter.prepareEmbeddingCall}. */\nexport interface PrepareEmbeddingOptions extends EmbeddingProfileInput {\n /** Caller overrides on the catalog's declared batch bounds. */\n readonly limits?: Partial<ResolvedEmbeddingBatchLimits>\n}\n\n/**\n * One adapter-owned embedding-resolution generation, bound to its dispatch call.\n *\n * The embedding counterpart of `PreparedAdapterCall`. Metadata, profile,\n * `spaceId`, and batch limits all come from the SAME capture as\n * {@link PreparedEmbeddingCall.embedBatch}, so dimensions can never be checked\n * against one configuration while the request goes out through another.\n */\nexport interface PreparedEmbeddingCall {\n /** Exact model metadata from the SAME generation as {@link embedBatch}. */\n readonly model: ResolvedEmbeddingModelInfo\n /** The `Embedding_Profile` this generation will actually produce vectors in. */\n readonly profile: EmbeddingProfile\n /** Canonical space identity derived from {@link profile}. */\n readonly spaceId: EmbeddingSpaceId\n /** From `embedding/limits.ts`, never from `composition/`. */\n readonly limits: ResolvedEmbeddingBatchLimits\n /** Dispatch through that generation, without re-reading dynamic connection facts. */\n embedBatch(\n batch: EmbeddingBatchRequest,\n context?: ModelInvocationContext,\n ): Promise<EmbeddingBatchResult>\n}\n\n/**\n * Provider-wire adapter for this SDK's embedding vocabulary.\n *\n * Contract obligations on implementations:\n * - exactly one `Provider_Attempt` per `embedBatch()` call; retry is the runtime's;\n * - honour `batch.signal` promptly;\n * - carry the original input index onto every returned vector;\n * - raise a protocol error when a response breaks the contract, never infer;\n * - include the SDK's attribution headers on every provider request.\n */\nexport abstract class EmbeddingAdapter {\n /**\n * Describe one provider route owned by this adapter.\n * @param provider - a route this instance was registered under.\n * @returns detached display metadata whose `id` MUST equal `provider`.\n */\n providerInfo(provider: string): ProviderInfo {\n return { id: provider, name: provider }\n }\n\n /**\n * The retry policy this route owns.\n * @param _provider - a route this instance was registered under.\n * @returns a resolved policy, or `undefined` to accept the runtime defaults.\n */\n providerRetryPolicy(_provider: string): ResolvedRetryPolicy | undefined {\n return undefined\n }\n\n /**\n * List embedding models this adapter can currently advertise for one route.\n *\n * ADVISORY only: absence from this list must never become a reason to reject a\n * request, because an adapter may accept ids it does not list.\n * @param _provider - one route owned by this adapter.\n * @returns discoverable models, in adapter-preferred order.\n */\n listEmbeddingModels(\n _provider: string,\n _signal?: AbortSignal,\n ): Promise<readonly EmbeddingModelInfo[]> {\n return Promise.resolve([])\n }\n\n /**\n * Resolve all metadata available for one exact embedding model.\n *\n * NOT request validation — an unknown id resolves to a minimal all-`unknown`\n * descriptor rather than an error.\n * @param provider - one route owned by this adapter.\n * @param model - exact model id.\n * @param _signal - cancellation; async implementations must settle promptly after abort.\n */\n resolveEmbeddingModel(\n provider: string,\n model: string,\n _signal?: AbortSignal,\n ): Promise<ResolvedEmbeddingModelInfo> {\n return Promise.resolve(unknownEmbeddingModel(provider, model))\n }\n\n /**\n * Declare the `Embedding_Profile` for one concrete call configuration.\n *\n * NOT abstract: the default derives a compatibility identity from\n * `${route}:${modelId}` when the catalog declares none, marks normalization\n * `'unknown'`, and applies no post-processing. That is what keeps this class at\n * exactly ONE abstract method. An adapter that owns the provider's real\n * statement about its embedding space MUST override.\n */\n embeddingProfile(\n model: ResolvedEmbeddingModelInfo,\n request: EmbeddingProfileInput,\n ): EmbeddingProfile {\n return defaultEmbeddingProfile(model, request)\n }\n\n /**\n * Bind resolved metadata to the exact configuration generation that will dispatch.\n *\n * Adapters whose connection facts come from mutable configuration MUST override\n * and snapshot those facts here.\n * @returns a frozen single-generation embedding entry point.\n */\n async prepareEmbeddingCall(\n provider: string,\n model: string,\n options: PrepareEmbeddingOptions,\n signal?: AbortSignal,\n context?: ModelInvocationContext,\n ): Promise<PreparedEmbeddingCall> {\n const resolved = await this.resolveEmbeddingModel(provider, model, signal)\n const profile = this.embeddingProfile(resolved, options)\n return Object.freeze({\n model: resolved,\n profile,\n // deriveSpaceId is synchronous: a canonical string, not a digest (DD-11).\n spaceId: deriveSpaceId(profile),\n limits: resolveBatchLimits(resolved, options.limits),\n embedBatch: (batch: EmbeddingBatchRequest, invocation = context) =>\n this.embedBatch(batch, invocation),\n })\n }\n\n /**\n * Perform EXACTLY ONE physical embedding request. The only required method.\n * @param batch - one `Physical_Batch`, already within the resolved limits.\n * @returns one vector per request item, each carrying its original index.\n */\n abstract embedBatch(\n batch: EmbeddingBatchRequest,\n context?: ModelInvocationContext,\n ): Promise<EmbeddingBatchResult>\n}\n"],"mappings":"gLAyEA,IAAsB,EAAtB,KAAuC,CAMrC,aAAa,EAAgC,CAC3C,MAAO,CAAE,GAAI,EAAU,KAAM,CAAS,CACxC,CAOA,oBAAoB,EAAoD,CAExE,CAUA,oBACE,EACA,EACwC,CACxC,OAAO,QAAQ,QAAQ,CAAC,CAAC,CAC3B,CAWA,sBACE,EACA,EACA,EACqC,CACrC,OAAO,QAAQ,QAAQ,EAAsB,EAAU,CAAK,CAAC,CAC/D,CAWA,iBACE,EACA,EACkB,CAClB,OAAO,EAAwB,EAAO,CAAO,CAC/C,CASA,MAAM,qBACJ,EACA,EACA,EACA,EACA,EACgC,CAChC,IAAM,EAAW,MAAM,KAAK,sBAAsB,EAAU,EAAO,CAAM,EACnE,EAAU,KAAK,iBAAiB,EAAU,CAAO,EACvD,OAAO,OAAO,OAAO,CACnB,MAAO,EACP,UAEA,QAAS,EAAc,CAAO,EAC9B,OAAQ,EAAmB,EAAU,EAAQ,MAAM,EACnD,YAAa,EAA8B,EAAa,IACtD,KAAK,WAAW,EAAO,CAAU,CACrC,CAAC,CACH,CAWF"}
@@ -0,0 +1,82 @@
1
+ import { EmbeddingNormalization, EmbeddingRepresentation } from "./profile.js";
2
+ import { EmbeddingPurposeHandling } from "./purpose.js";
3
+ //#region src/embedding/catalog.d.ts
4
+ /**
5
+ * A single catalog capability in one of exactly three states.
6
+ *
7
+ * `'unsupported'` is a positive negative claim — the route states it does not
8
+ * have the thing. `'unknown'` states nothing at all. Collapsing the two would
9
+ * let a missing declaration masquerade as a denial, which is what Requirement
10
+ * 10.4 rules out.
11
+ */
12
+ type EmbeddingCapability<T> = {
13
+ readonly state: 'supported';
14
+ readonly value: T;
15
+ } | {
16
+ readonly state: 'unsupported';
17
+ } | {
18
+ readonly state: 'unknown';
19
+ };
20
+ /**
21
+ * Accepted input kinds. v1 declares exactly one.
22
+ *
23
+ * There is no value here for images, audio or any other modality, so the v1
24
+ * text-only scope is readable from the type rather than from prose
25
+ * (Requirements 8.6, 8.8).
26
+ */
27
+ type EmbeddingInputType = 'text';
28
+ /**
29
+ * One embedding model a route can advertise.
30
+ *
31
+ * Catalog membership is ADVISORY, exactly as it is for generation: an adapter
32
+ * may accept an id it does not list.
33
+ */
34
+ interface EmbeddingModelInfo {
35
+ /** Provider route that owns this entry. */
36
+ readonly provider: string;
37
+ /** Model id passed to `embed()`/`embedMany()`. */
38
+ readonly id: string;
39
+ /** Human-readable name for selectors. */
40
+ readonly name: string;
41
+ /** Optional user-facing distinction from otherwise similar models. */
42
+ readonly description?: string;
43
+ /** Accepted input kinds; v1 has only {@link EmbeddingInputType}. */
44
+ readonly inputTypes: EmbeddingCapability<readonly EmbeddingInputType[]>;
45
+ /** Output shape; v1 has only `'dense-float32'`, one dense vector per item. */
46
+ readonly representation: EmbeddingCapability<EmbeddingRepresentation>;
47
+ /** Selectable vector widths. */
48
+ readonly dimensions: EmbeddingCapability<readonly number[]>;
49
+ /** Width used when the caller requests none. */
50
+ readonly defaultDimensions: EmbeddingCapability<number>;
51
+ /** Per-input token ceiling. Only a `supported` value may reject an input. */
52
+ readonly maxInputTokens: EmbeddingCapability<number>;
53
+ /** Items accepted in one physical batch. */
54
+ readonly maxBatchItems: EmbeddingCapability<number>;
55
+ /** Estimated tokens accepted in one physical batch. */
56
+ readonly maxBatchTokens: EmbeddingCapability<number>;
57
+ /** Payload bytes accepted in one physical batch. */
58
+ readonly maxBatchBytes: EmbeddingCapability<number>;
59
+ /** How the route expresses purpose on the wire. */
60
+ readonly purposeHandling: EmbeddingCapability<EmbeddingPurposeHandling>;
61
+ /** Whether vectors arrive normalized. Never inferred from dimension count. */
62
+ readonly normalization: EmbeddingCapability<EmbeddingNormalization>;
63
+ /** The provider's own declaration about the embedding space. */
64
+ readonly compatibilityIdentity: EmbeddingCapability<string>;
65
+ }
66
+ /** Exact-route embedding metadata, resolved by the adapter that owns the route. */
67
+ interface ResolvedEmbeddingModelInfo extends EmbeddingModelInfo {
68
+ /** Provider-declared model revision, when the route exposes one. */
69
+ readonly modelRevision?: string;
70
+ }
71
+ /**
72
+ * The minimal descriptor for an id the catalog does not describe: identity only,
73
+ * every capability `unknown`.
74
+ *
75
+ * This is what keeps an unlisted model id usable (Requirement 10.3). Consumers
76
+ * then split by intent: validation must NOT reject on `unknown`, while batching
77
+ * falls back to `EMBEDDING_BATCH_DEFAULTS` so memory stays bounded (DD-6).
78
+ */
79
+ declare function unknownEmbeddingModel(provider: string, model: string): ResolvedEmbeddingModelInfo;
80
+ //#endregion
81
+ export { EmbeddingCapability, EmbeddingInputType, EmbeddingModelInfo, ResolvedEmbeddingModelInfo, unknownEmbeddingModel };
82
+ //# sourceMappingURL=catalog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalog.d.ts","names":[],"sources":["../../src/embedding/catalog.ts"],"mappings":";;;;;;;;;;;KAwBY,oBAAoB;WACjB;WAA6B,OAAO;;WACpC;;WACA;;;;;;;;;KASH;;;;;;;UAWK;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA,YAAY,6BAA6B;;WAEzC,gBAAgB,oBAAoB;;WAEpC,YAAY;;WAEZ,mBAAmB;;WAEnB,gBAAgB;;WAEhB,eAAe;;WAEf,gBAAgB;;WAEhB,eAAe;;WAEf,iBAAiB,oBAAoB;;WAErC,eAAe,oBAAoB;;WAEnC,uBAAuB;;;UAIjB,mCAAmC;;WAEzC;;;;;;;;;;iBAWK,sBACd,kBACA,gBACC"}
@@ -0,0 +1,2 @@
1
+ const e=Object.freeze({state:`unknown`});function t(t,n){return{provider:t,id:n,name:n,inputTypes:e,representation:e,dimensions:e,defaultDimensions:e,maxInputTokens:e,maxBatchItems:e,maxBatchTokens:e,maxBatchBytes:e,purposeHandling:e,normalization:e,compatibilityIdentity:e}}export{t as unknownEmbeddingModel};
2
+ //# sourceMappingURL=catalog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalog.js","names":[],"sources":["../../src/embedding/catalog.ts"],"sourcesContent":["/**\n * `Embedding_Catalog`: embedding-specific model metadata, kept entirely separate\n * from {@link ResolvedModelInfo}.\n *\n * Generation metadata and embedding metadata answer different questions, so this\n * module adds NO field to the generation catalog. Every capability that is not\n * declared explicitly is `unknown`, and `unknown` is never a reason to reject a\n * request: an id outside the catalog stays usable and the provider decides\n * (Requirements 10.1, 10.3, 10.4, 10.5).\n *\n * @module ai-agent-sdk/core/embedding/catalog\n */\n\nimport type { EmbeddingNormalization, EmbeddingRepresentation } from './profile.ts'\nimport type { EmbeddingPurposeHandling } from './purpose.ts'\n\n/**\n * A single catalog capability in one of exactly three states.\n *\n * `'unsupported'` is a positive negative claim — the route states it does not\n * have the thing. `'unknown'` states nothing at all. Collapsing the two would\n * let a missing declaration masquerade as a denial, which is what Requirement\n * 10.4 rules out.\n */\nexport type EmbeddingCapability<T> =\n | { readonly state: 'supported'; readonly value: T }\n | { readonly state: 'unsupported' }\n | { readonly state: 'unknown' }\n\n/**\n * Accepted input kinds. v1 declares exactly one.\n *\n * There is no value here for images, audio or any other modality, so the v1\n * text-only scope is readable from the type rather than from prose\n * (Requirements 8.6, 8.8).\n */\nexport type EmbeddingInputType = 'text'\n\n/** The `unknown` capability, shared so descriptors need not re-allocate it. */\nconst UNKNOWN: EmbeddingCapability<never> = Object.freeze({ state: 'unknown' })\n\n/**\n * One embedding model a route can advertise.\n *\n * Catalog membership is ADVISORY, exactly as it is for generation: an adapter\n * may accept an id it does not list.\n */\nexport interface EmbeddingModelInfo {\n /** Provider route that owns this entry. */\n readonly provider: string\n /** Model id passed to `embed()`/`embedMany()`. */\n readonly id: string\n /** Human-readable name for selectors. */\n readonly name: string\n /** Optional user-facing distinction from otherwise similar models. */\n readonly description?: string\n /** Accepted input kinds; v1 has only {@link EmbeddingInputType}. */\n readonly inputTypes: EmbeddingCapability<readonly EmbeddingInputType[]>\n /** Output shape; v1 has only `'dense-float32'`, one dense vector per item. */\n readonly representation: EmbeddingCapability<EmbeddingRepresentation>\n /** Selectable vector widths. */\n readonly dimensions: EmbeddingCapability<readonly number[]>\n /** Width used when the caller requests none. */\n readonly defaultDimensions: EmbeddingCapability<number>\n /** Per-input token ceiling. Only a `supported` value may reject an input. */\n readonly maxInputTokens: EmbeddingCapability<number>\n /** Items accepted in one physical batch. */\n readonly maxBatchItems: EmbeddingCapability<number>\n /** Estimated tokens accepted in one physical batch. */\n readonly maxBatchTokens: EmbeddingCapability<number>\n /** Payload bytes accepted in one physical batch. */\n readonly maxBatchBytes: EmbeddingCapability<number>\n /** How the route expresses purpose on the wire. */\n readonly purposeHandling: EmbeddingCapability<EmbeddingPurposeHandling>\n /** Whether vectors arrive normalized. Never inferred from dimension count. */\n readonly normalization: EmbeddingCapability<EmbeddingNormalization>\n /** The provider's own declaration about the embedding space. */\n readonly compatibilityIdentity: EmbeddingCapability<string>\n}\n\n/** Exact-route embedding metadata, resolved by the adapter that owns the route. */\nexport interface ResolvedEmbeddingModelInfo extends EmbeddingModelInfo {\n /** Provider-declared model revision, when the route exposes one. */\n readonly modelRevision?: string\n}\n\n/**\n * The minimal descriptor for an id the catalog does not describe: identity only,\n * every capability `unknown`.\n *\n * This is what keeps an unlisted model id usable (Requirement 10.3). Consumers\n * then split by intent: validation must NOT reject on `unknown`, while batching\n * falls back to `EMBEDDING_BATCH_DEFAULTS` so memory stays bounded (DD-6).\n */\nexport function unknownEmbeddingModel(\n provider: string,\n model: string,\n): ResolvedEmbeddingModelInfo {\n return {\n provider,\n id: model,\n name: model,\n inputTypes: UNKNOWN,\n representation: UNKNOWN,\n dimensions: UNKNOWN,\n defaultDimensions: UNKNOWN,\n maxInputTokens: UNKNOWN,\n maxBatchItems: UNKNOWN,\n maxBatchTokens: UNKNOWN,\n maxBatchBytes: UNKNOWN,\n purposeHandling: UNKNOWN,\n normalization: UNKNOWN,\n compatibilityIdentity: UNKNOWN,\n }\n}\n"],"mappings":"AAuCA,MAAM,EAAsC,OAAO,OAAO,CAAE,MAAO,SAAU,CAAC,EAuD9E,SAAgB,EACd,EACA,EAC4B,CAC5B,MAAO,CACL,WACA,GAAI,EACJ,KAAM,EACN,WAAY,EACZ,eAAgB,EAChB,WAAY,EACZ,kBAAmB,EACnB,eAAgB,EAChB,cAAe,EACf,eAAgB,EAChB,cAAe,EACf,gBAAiB,EACjB,cAAe,EACf,sBAAuB,CACzB,CACF"}
@@ -0,0 +1,98 @@
1
+ import { AgentSdkError } from "../errors/agent-sdk-error.js";
2
+ import { EmbeddingSpaceId } from "./profile.js";
3
+ //#region src/embedding/errors.d.ts
4
+ /**
5
+ * Codes produced by the embedding contract and runtime.
6
+ *
7
+ * A frozen object rather than a TS enum, matching `MODEL_ERROR_CODES`, so a
8
+ * third-party embedding adapter can emit its own code without this union having
9
+ * to know about it. Values are prefixed `EMBEDDING_` because they travel beside
10
+ * generation codes in the same failure envelopes.
11
+ */
12
+ declare const EMBEDDING_ERROR_CODES: Readonly<{
13
+ /** No `Embedding_Adapter` is registered for the requested route/model. */
14
+ readonly ADAPTER_MISSING: 'EMBEDDING_ADAPTER_MISSING';
15
+ /** Malformed at the SDK boundary: missing purpose, empty values, empty item. */
16
+ readonly REQUEST_INVALID: 'EMBEDDING_REQUEST_INVALID';
17
+ /** `dimensions` is not among the widths the route declares support for. */
18
+ readonly DIMENSIONS_UNSUPPORTED: 'EMBEDDING_DIMENSIONS_UNSUPPORTED';
19
+ /** Input exceeds the declared max input tokens; carries `itemIndexes` and `limit`. */
20
+ readonly INPUT_TOO_LARGE: 'EMBEDDING_INPUT_TOO_LARGE';
21
+ /** The expected `Space_Id` is incompatible with the `Prepared_Embedding_Call`. */
22
+ readonly SPACE_INCOMPATIBLE: 'EMBEDDING_SPACE_INCOMPATIBLE';
23
+ /** The route has no way to express this purpose and the caller demands the distinction. */
24
+ readonly PURPOSE_UNSUPPORTED: 'EMBEDDING_PURPOSE_UNSUPPORTED';
25
+ /** The caller asked for truncation but the provider has no equivalent parameter. */
26
+ readonly TRUNCATION_UNSUPPORTED: 'EMBEDDING_TRUNCATION_UNSUPPORTED';
27
+ /** The response carried a different number of vectors than inputs sent. */
28
+ readonly VECTOR_COUNT_MISMATCH: 'EMBEDDING_VECTOR_COUNT_MISMATCH';
29
+ /** A vector index is duplicated, missing, or out of range. */
30
+ readonly VECTOR_INDEX_INVALID: 'EMBEDDING_VECTOR_INDEX_INVALID';
31
+ /** A vector contains `NaN` or `Infinity`. */
32
+ readonly VECTOR_VALUE_INVALID: 'EMBEDDING_VECTOR_VALUE_INVALID';
33
+ /** A vector's width differs from the requested `dimensions`. */
34
+ readonly VECTOR_DIMENSIONS_MISMATCH: 'EMBEDDING_VECTOR_DIMENSIONS_MISMATCH';
35
+ /** The response does not satisfy the embedding contract structurally. */
36
+ readonly RESPONSE_MALFORMED: 'EMBEDDING_RESPONSE_MALFORMED';
37
+ /** The caller's signal or a runtime close aborted the call. */
38
+ readonly ABORTED: 'EMBEDDING_ABORTED';
39
+ /** Invalid handle configuration: cache enabled without scope, fallback outside the group. */
40
+ readonly CONFIGURATION_INVALID: 'EMBEDDING_CONFIGURATION_INVALID';
41
+ /** Nothing in this taxonomy classified the embedding failure. */
42
+ readonly UNKNOWN: 'EMBEDDING_UNKNOWN';
43
+ }>;
44
+ /** Any value of {@link EMBEDDING_ERROR_CODES}; a foreign adapter may still use its own `string`. */
45
+ type EmbeddingErrorCode = typeof EMBEDDING_ERROR_CODES[keyof typeof EMBEDDING_ERROR_CODES];
46
+ /** Structured embedding facts and cause accepted by {@link EmbeddingError}. */
47
+ interface EmbeddingErrorOptions extends ErrorOptions {
48
+ /**
49
+ * Zero-based indexes of the request items this failure belongs to.
50
+ *
51
+ * Present only when the fault is attributable to specific inputs, which is
52
+ * what lets a caller drop or re-chunk those items instead of the whole call.
53
+ */
54
+ itemIndexes?: readonly number[];
55
+ /** The limit that was applied, when the failure is a limit violation. */
56
+ limit?: number;
57
+ /** Provider id of the route that produced the failure. */
58
+ provider?: string;
59
+ /** Model id of the route that produced the failure. */
60
+ model?: string;
61
+ /** The embedding space involved, when the failure concerns space compatibility. */
62
+ space?: EmbeddingSpaceId;
63
+ }
64
+ /**
65
+ * Typed error for embedding failures, carrying a stable `code` plus the facts a
66
+ * caller needs to act without re-deriving them.
67
+ *
68
+ * The constructor validates rather than trusts: `itemIndexes` must be
69
+ * non-negative integers and `limit` a positive finite number. A negative index
70
+ * or a `limit` of `-1` means a caller upstream miscomputed a bound, and letting
71
+ * it through would surface a nonsense limit in a message that reads as
72
+ * authoritative. Indexes are copied and frozen so the array cannot be mutated
73
+ * after the error is thrown.
74
+ *
75
+ * No field carries raw input text or vector values: redaction rules keep those
76
+ * out of errors and traces alike.
77
+ */
78
+ declare class EmbeddingError extends AgentSdkError {
79
+ /** Request item indexes this failure belongs to, when input-specific. */
80
+ readonly itemIndexes?: readonly number[];
81
+ /** The applied limit, when the failure is a limit violation. */
82
+ readonly limit?: number;
83
+ /** Provider id of the failing route. */
84
+ readonly provider?: string;
85
+ /** Model id of the failing route. */
86
+ readonly model?: string;
87
+ /** The embedding space involved in the failure. */
88
+ readonly space?: EmbeddingSpaceId;
89
+ /**
90
+ * @param message - non-empty human-readable failure summary, free of credentials and raw input.
91
+ * @param code - non-empty stable machine code, normally from {@link EMBEDDING_ERROR_CODES}.
92
+ * @param options - optional cause and validated embedding facts.
93
+ */
94
+ constructor(message: string, code: string, options?: EmbeddingErrorOptions);
95
+ }
96
+ //#endregion
97
+ export { EMBEDDING_ERROR_CODES, EmbeddingError, EmbeddingErrorCode, EmbeddingErrorOptions };
98
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","names":[],"sources":["../../src/embedding/errors.ts"],"mappings":";;;;;;;;;;;cA2Ba,uBAAqB;;WAEf;;WAEA;;WAEO;;WAEP;;WAEG;;WAEC;;WAEG;;WAED;;WAED;;WAEA;;WAEM;;WAER;;WAEX;;WAEc;;WAEd;;;KAIC,4BAA4B,mCAAmC;;UAG1D,8BAA8B;;;;;;;EAO7C;;EAEA;;EAEA;;EAEA;;EAEA,QAAQ;;;;;;;;;;;;;;;;cAiBG,uBAAuB;;WAEzB;;WAEA;;WAEA;;WAEA;;WAEA,QAAQ;;;;;;EAOjB,YAAY,iBAAiB,cAAc,UAAU"}
@@ -0,0 +1,2 @@
1
+ import{AgentSdkError as e}from"../errors/agent-sdk-error.js";const t=Object.freeze({ADAPTER_MISSING:`EMBEDDING_ADAPTER_MISSING`,REQUEST_INVALID:`EMBEDDING_REQUEST_INVALID`,DIMENSIONS_UNSUPPORTED:`EMBEDDING_DIMENSIONS_UNSUPPORTED`,INPUT_TOO_LARGE:`EMBEDDING_INPUT_TOO_LARGE`,SPACE_INCOMPATIBLE:`EMBEDDING_SPACE_INCOMPATIBLE`,PURPOSE_UNSUPPORTED:`EMBEDDING_PURPOSE_UNSUPPORTED`,TRUNCATION_UNSUPPORTED:`EMBEDDING_TRUNCATION_UNSUPPORTED`,VECTOR_COUNT_MISMATCH:`EMBEDDING_VECTOR_COUNT_MISMATCH`,VECTOR_INDEX_INVALID:`EMBEDDING_VECTOR_INDEX_INVALID`,VECTOR_VALUE_INVALID:`EMBEDDING_VECTOR_VALUE_INVALID`,VECTOR_DIMENSIONS_MISMATCH:`EMBEDDING_VECTOR_DIMENSIONS_MISMATCH`,RESPONSE_MALFORMED:`EMBEDDING_RESPONSE_MALFORMED`,ABORTED:`EMBEDDING_ABORTED`,CONFIGURATION_INVALID:`EMBEDDING_CONFIGURATION_INVALID`,UNKNOWN:`EMBEDDING_UNKNOWN`});var n=class extends e{itemIndexes;limit;provider;model;space;constructor(e,t,n){if(typeof e!=`string`||e.length===0)throw Error(`EmbeddingError message must be a non-empty string`);if(typeof t!=`string`||t.length===0)throw Error(`EmbeddingError code must be a non-empty string`);if(n?.itemIndexes!==void 0&&(!Array.isArray(n.itemIndexes)||n.itemIndexes.some(e=>!Number.isInteger(e)||e<0)))throw Error(`EmbeddingError itemIndexes must be an array of non-negative integers`);if(n?.limit!==void 0&&(!Number.isFinite(n.limit)||n.limit<=0))throw Error(`EmbeddingError limit must be a positive finite number`);if(n?.provider!==void 0&&(typeof n.provider!=`string`||n.provider.length===0))throw Error(`EmbeddingError provider must be a non-empty string`);if(n?.model!==void 0&&(typeof n.model!=`string`||n.model.length===0))throw Error(`EmbeddingError model must be a non-empty string`);if(n?.space!==void 0&&(typeof n.space!=`string`||n.space.length===0))throw Error(`EmbeddingError space must be a non-empty string`);super(e,t,n),this.name=`EmbeddingError`,n?.itemIndexes!==void 0&&(this.itemIndexes=Object.freeze([...n.itemIndexes])),n?.limit!==void 0&&(this.limit=n.limit),n?.provider!==void 0&&(this.provider=n.provider),n?.model!==void 0&&(this.model=n.model),n?.space!==void 0&&(this.space=n.space)}};export{t as EMBEDDING_ERROR_CODES,n as EmbeddingError};
2
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","names":[],"sources":["../../src/embedding/errors.ts"],"sourcesContent":["/**\n * The stable embedding failure taxonomy, and the error the embedding layers throw.\n *\n * Codes here are owned by two layers only: `Embedding_Runtime` before dispatch\n * (dimensions, limits, space, configuration) and `Embedding_Adapter` when it\n * validates a response (vector count, index, values, width). Transport-level\n * faults keep using `MODEL_ERROR_CODES`, so a caller can tell \"the provider is\n * rate limiting us\" apart from \"the provider returned a vector of the wrong\n * width\" without parsing any message.\n *\n * Both provider adapters emit the SAME codes for mapping, dimensions and vector\n * faults. That is what lets one contract-test suite run against both.\n *\n * @module ai-agent-sdk/core/embedding/errors\n */\n\nimport { AgentSdkError } from '../errors/agent-sdk-error.ts'\nimport type { EmbeddingSpaceId } from './profile.ts'\n\n/**\n * Codes produced by the embedding contract and runtime.\n *\n * A frozen object rather than a TS enum, matching `MODEL_ERROR_CODES`, so a\n * third-party embedding adapter can emit its own code without this union having\n * to know about it. Values are prefixed `EMBEDDING_` because they travel beside\n * generation codes in the same failure envelopes.\n */\nexport const EMBEDDING_ERROR_CODES = Object.freeze({\n /** No `Embedding_Adapter` is registered for the requested route/model. */\n ADAPTER_MISSING: 'EMBEDDING_ADAPTER_MISSING',\n /** Malformed at the SDK boundary: missing purpose, empty values, empty item. */\n REQUEST_INVALID: 'EMBEDDING_REQUEST_INVALID',\n /** `dimensions` is not among the widths the route declares support for. */\n DIMENSIONS_UNSUPPORTED: 'EMBEDDING_DIMENSIONS_UNSUPPORTED',\n /** Input exceeds the declared max input tokens; carries `itemIndexes` and `limit`. */\n INPUT_TOO_LARGE: 'EMBEDDING_INPUT_TOO_LARGE',\n /** The expected `Space_Id` is incompatible with the `Prepared_Embedding_Call`. */\n SPACE_INCOMPATIBLE: 'EMBEDDING_SPACE_INCOMPATIBLE',\n /** The route has no way to express this purpose and the caller demands the distinction. */\n PURPOSE_UNSUPPORTED: 'EMBEDDING_PURPOSE_UNSUPPORTED',\n /** The caller asked for truncation but the provider has no equivalent parameter. */\n TRUNCATION_UNSUPPORTED: 'EMBEDDING_TRUNCATION_UNSUPPORTED',\n /** The response carried a different number of vectors than inputs sent. */\n VECTOR_COUNT_MISMATCH: 'EMBEDDING_VECTOR_COUNT_MISMATCH',\n /** A vector index is duplicated, missing, or out of range. */\n VECTOR_INDEX_INVALID: 'EMBEDDING_VECTOR_INDEX_INVALID',\n /** A vector contains `NaN` or `Infinity`. */\n VECTOR_VALUE_INVALID: 'EMBEDDING_VECTOR_VALUE_INVALID',\n /** A vector's width differs from the requested `dimensions`. */\n VECTOR_DIMENSIONS_MISMATCH: 'EMBEDDING_VECTOR_DIMENSIONS_MISMATCH',\n /** The response does not satisfy the embedding contract structurally. */\n RESPONSE_MALFORMED: 'EMBEDDING_RESPONSE_MALFORMED',\n /** The caller's signal or a runtime close aborted the call. */\n ABORTED: 'EMBEDDING_ABORTED',\n /** Invalid handle configuration: cache enabled without scope, fallback outside the group. */\n CONFIGURATION_INVALID: 'EMBEDDING_CONFIGURATION_INVALID',\n /** Nothing in this taxonomy classified the embedding failure. */\n UNKNOWN: 'EMBEDDING_UNKNOWN',\n} as const)\n\n/** Any value of {@link EMBEDDING_ERROR_CODES}; a foreign adapter may still use its own `string`. */\nexport type EmbeddingErrorCode = typeof EMBEDDING_ERROR_CODES[keyof typeof EMBEDDING_ERROR_CODES]\n\n/** Structured embedding facts and cause accepted by {@link EmbeddingError}. */\nexport interface EmbeddingErrorOptions extends ErrorOptions {\n /**\n * Zero-based indexes of the request items this failure belongs to.\n *\n * Present only when the fault is attributable to specific inputs, which is\n * what lets a caller drop or re-chunk those items instead of the whole call.\n */\n itemIndexes?: readonly number[]\n /** The limit that was applied, when the failure is a limit violation. */\n limit?: number\n /** Provider id of the route that produced the failure. */\n provider?: string\n /** Model id of the route that produced the failure. */\n model?: string\n /** The embedding space involved, when the failure concerns space compatibility. */\n space?: EmbeddingSpaceId\n}\n\n/**\n * Typed error for embedding failures, carrying a stable `code` plus the facts a\n * caller needs to act without re-deriving them.\n *\n * The constructor validates rather than trusts: `itemIndexes` must be\n * non-negative integers and `limit` a positive finite number. A negative index\n * or a `limit` of `-1` means a caller upstream miscomputed a bound, and letting\n * it through would surface a nonsense limit in a message that reads as\n * authoritative. Indexes are copied and frozen so the array cannot be mutated\n * after the error is thrown.\n *\n * No field carries raw input text or vector values: redaction rules keep those\n * out of errors and traces alike.\n */\nexport class EmbeddingError extends AgentSdkError {\n /** Request item indexes this failure belongs to, when input-specific. */\n readonly itemIndexes?: readonly number[]\n /** The applied limit, when the failure is a limit violation. */\n readonly limit?: number\n /** Provider id of the failing route. */\n readonly provider?: string\n /** Model id of the failing route. */\n readonly model?: string\n /** The embedding space involved in the failure. */\n readonly space?: EmbeddingSpaceId\n\n /**\n * @param message - non-empty human-readable failure summary, free of credentials and raw input.\n * @param code - non-empty stable machine code, normally from {@link EMBEDDING_ERROR_CODES}.\n * @param options - optional cause and validated embedding facts.\n */\n constructor(message: string, code: string, options?: EmbeddingErrorOptions) {\n if (typeof message !== 'string' || message.length === 0) {\n throw new Error('EmbeddingError message must be a non-empty string')\n }\n if (typeof code !== 'string' || code.length === 0) {\n throw new Error('EmbeddingError code must be a non-empty string')\n }\n if (options?.itemIndexes !== undefined\n && (!Array.isArray(options.itemIndexes)\n || options.itemIndexes.some(index => !Number.isInteger(index) || index < 0))) {\n throw new Error('EmbeddingError itemIndexes must be an array of non-negative integers')\n }\n if (options?.limit !== undefined\n && (!Number.isFinite(options.limit) || options.limit <= 0)) {\n throw new Error('EmbeddingError limit must be a positive finite number')\n }\n if (options?.provider !== undefined\n && (typeof options.provider !== 'string' || options.provider.length === 0)) {\n throw new Error('EmbeddingError provider must be a non-empty string')\n }\n if (options?.model !== undefined\n && (typeof options.model !== 'string' || options.model.length === 0)) {\n throw new Error('EmbeddingError model must be a non-empty string')\n }\n if (options?.space !== undefined\n && (typeof options.space !== 'string' || options.space.length === 0)) {\n throw new Error('EmbeddingError space must be a non-empty string')\n }\n super(message, code, options)\n this.name = 'EmbeddingError'\n if (options?.itemIndexes !== undefined) {\n this.itemIndexes = Object.freeze([...options.itemIndexes])\n }\n if (options?.limit !== undefined) this.limit = options.limit\n if (options?.provider !== undefined) this.provider = options.provider\n if (options?.model !== undefined) this.model = options.model\n if (options?.space !== undefined) this.space = options.space\n }\n}\n"],"mappings":"6DA2BA,MAAa,EAAwB,OAAO,OAAO,CAEjD,gBAAiB,4BAEjB,gBAAiB,4BAEjB,uBAAwB,mCAExB,gBAAiB,4BAEjB,mBAAoB,+BAEpB,oBAAqB,gCAErB,uBAAwB,mCAExB,sBAAuB,kCAEvB,qBAAsB,iCAEtB,qBAAsB,iCAEtB,2BAA4B,uCAE5B,mBAAoB,+BAEpB,QAAS,oBAET,sBAAuB,kCAEvB,QAAS,mBACX,CAAU,EAsCV,IAAa,EAAb,cAAoC,CAAc,CAEhD,YAEA,MAEA,SAEA,MAEA,MAOA,YAAY,EAAiB,EAAc,EAAiC,CAC1E,GAAI,OAAO,GAAY,UAAY,EAAQ,SAAW,EACpD,MAAU,MAAM,mDAAmD,EAErE,GAAI,OAAO,GAAS,UAAY,EAAK,SAAW,EAC9C,MAAU,MAAM,gDAAgD,EAElE,GAAI,GAAS,cAAgB,IAAA,KACvB,CAAC,MAA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