@semiont/core 0.5.3 → 0.5.5

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/dist/index.js CHANGED
@@ -60,17 +60,6 @@ function resourceAnnotationUri(uri) {
60
60
  return uri;
61
61
  }
62
62
 
63
- // src/creation-methods.ts
64
- var CREATION_METHODS = {
65
- API: "api",
66
- UPLOAD: "upload",
67
- UI: "ui",
68
- REFERENCE: "reference",
69
- CLI: "cli",
70
- CLONE: "clone",
71
- GENERATED: "generated"
72
- };
73
-
74
63
  // src/identifiers.ts
75
64
  function isResourceId(value) {
76
65
  return !value.includes("/");
@@ -1583,24 +1572,57 @@ var ConflictError = class extends SemiontError {
1583
1572
  function userToDid(user) {
1584
1573
  return `did:web:${user.domain}:users:${encodeURIComponent(user.email)}`;
1585
1574
  }
1575
+ function agentToDid(agent) {
1576
+ return `did:web:${agent.domain}:agents:${encodeURIComponent(agent.provider)}:${encodeURIComponent(agent.model)}`;
1577
+ }
1586
1578
  function userToAgent(user) {
1587
1579
  return {
1588
- type: "Person",
1589
- id: userToDid(user),
1580
+ "@type": "Person",
1581
+ "@id": userToDid(user),
1590
1582
  name: user.name || user.email
1591
1583
  };
1592
1584
  }
1585
+ function softwareToAgent(software) {
1586
+ return {
1587
+ "@type": "Software",
1588
+ "@id": agentToDid(software),
1589
+ name: `${software.provider} ${software.model}`,
1590
+ provider: software.provider,
1591
+ model: software.model,
1592
+ ...software.parameters && { parameters: software.parameters }
1593
+ };
1594
+ }
1593
1595
  function didToAgent(did) {
1594
1596
  if (!did) {
1595
- return { type: "Person", id: "unknown", name: "unknown" };
1597
+ return { "@type": "Person", "@id": "unknown", name: "unknown" };
1596
1598
  }
1597
1599
  const parts = did.split(":");
1600
+ const agentsIdx = parts.lastIndexOf("agents");
1601
+ const usersIdx = parts.lastIndexOf("users");
1602
+ if (agentsIdx >= 0 && agentsIdx === parts.length - 3) {
1603
+ const provider = decodeURIComponent(parts[agentsIdx + 1] ?? "");
1604
+ const model = decodeURIComponent(parts[agentsIdx + 2] ?? "");
1605
+ return {
1606
+ "@type": "Software",
1607
+ "@id": did,
1608
+ name: `${provider} ${model}`,
1609
+ provider,
1610
+ model
1611
+ };
1612
+ }
1613
+ if (usersIdx >= 0 && usersIdx === parts.length - 2) {
1614
+ const name = decodeURIComponent(parts[usersIdx + 1] ?? "");
1615
+ return {
1616
+ "@type": "Person",
1617
+ "@id": did,
1618
+ name
1619
+ };
1620
+ }
1598
1621
  const encoded = parts[parts.length - 1] || "unknown";
1599
- const name = decodeURIComponent(encoded);
1600
1622
  return {
1601
- type: "Person",
1602
- id: did,
1603
- name
1623
+ "@type": "Person",
1624
+ "@id": did,
1625
+ name: decodeURIComponent(encoded)
1604
1626
  };
1605
1627
  }
1606
1628
  function deepMerge(base, override) {
@@ -1943,6 +1965,6 @@ function getAllPlatformTypes() {
1943
1965
  var CORE_TYPES_VERSION = "0.1.0";
1944
1966
  var SDK_VERSION = "0.1.0";
1945
1967
 
1946
- export { BRIDGED_CHANNELS, CHANNEL_SCHEMAS, CORE_TYPES_VERSION, CREATION_METHODS, ConfigurationError, ConflictError, EventBus, JWTTokenSchema, LOCALES, NotFoundError, PERSISTED_EVENT_TYPES, RESOURCE_BROADCAST_TYPES, SDK_VERSION, ScopedEventBus, ScriptError, SemiontError, UnauthorizedError, ValidationError, accessToken, annotationId, annotationUri, applyBodyOperations, assembleAnnotation, authCode, baseUrl, buildContentCache, burstBuffer, busLog, busLogEnabled, cloneToken, createCircleSvg, createPolygonSvg, createRectangleSvg, createTomlConfigLoader, decodeRepresentation, decodeWithCharset, didToAgent, email, entityType, errField, extractBoundingBox, extractCharset, extractContext, findBestTextMatch, findBodyItem, findTextWithContext, formatLocaleDisplay, generateUuid, getAllLocaleCodes, getAllPlatformTypes, getAnnotationExactText, getAnnotationUriFromEvent, getBodySource, getBodyType, getChecksum, getCommentText, getCreator, getDerivedFrom, getExactText, getExtensionForMimeType, getFragmentSelector, getLanguage, getLocaleEnglishName, getLocaleInfo, getLocaleNativeName, getMimeCategory, getNodeEncoding, getPrimaryMediaType, getPrimaryRepresentation, getPrimarySelector, getResourceEntityTypes, getResourceId, getStorageUri, getSvgSelector, getTargetSelector, getTargetSource, getTextPositionSelector, getTextQuoteSelector, googleCredential, hasTargetSelector, isAnnotationId, isArchived, isArray, isAssessment, isBodyResolved, isBoolean, isComment, isDefined, isDraft, isEventRelatedToAnnotation, isFunction, isHighlight, isImageMimeType, isNull, isNullish, isNumber, isObject, isPdfMimeType, isReference, isResolvedReference, isResourceId, isStoredEvent, isString, isStubReference, isTag, isTextMimeType, isUndefined, isValidEmail, isValidPlatformType, jobId, loadTomlConfig, mcpToken, normalizeCoordinates, normalizeText, parseEnvironment, parseSvgSelector, refreshToken, resourceAnnotationUri, resourceId, resourceUri, scaleSvgToNative, searchQuery, serializePerKey, setBusLogTraceIdProvider, userDID, userId, userToAgent, userToDid, validateAndCorrectOffsets, validateData, validateEnvironment, validateSvgMarkup, verifyPosition };
1968
+ export { BRIDGED_CHANNELS, CHANNEL_SCHEMAS, CORE_TYPES_VERSION, ConfigurationError, ConflictError, EventBus, JWTTokenSchema, LOCALES, NotFoundError, PERSISTED_EVENT_TYPES, RESOURCE_BROADCAST_TYPES, SDK_VERSION, ScopedEventBus, ScriptError, SemiontError, UnauthorizedError, ValidationError, accessToken, agentToDid, annotationId, annotationUri, applyBodyOperations, assembleAnnotation, authCode, baseUrl, buildContentCache, burstBuffer, busLog, busLogEnabled, cloneToken, createCircleSvg, createPolygonSvg, createRectangleSvg, createTomlConfigLoader, decodeRepresentation, decodeWithCharset, didToAgent, email, entityType, errField, extractBoundingBox, extractCharset, extractContext, findBestTextMatch, findBodyItem, findTextWithContext, formatLocaleDisplay, generateUuid, getAllLocaleCodes, getAllPlatformTypes, getAnnotationExactText, getAnnotationUriFromEvent, getBodySource, getBodyType, getChecksum, getCommentText, getCreator, getDerivedFrom, getExactText, getExtensionForMimeType, getFragmentSelector, getLanguage, getLocaleEnglishName, getLocaleInfo, getLocaleNativeName, getMimeCategory, getNodeEncoding, getPrimaryMediaType, getPrimaryRepresentation, getPrimarySelector, getResourceEntityTypes, getResourceId, getStorageUri, getSvgSelector, getTargetSelector, getTargetSource, getTextPositionSelector, getTextQuoteSelector, googleCredential, hasTargetSelector, isAnnotationId, isArchived, isArray, isAssessment, isBodyResolved, isBoolean, isComment, isDefined, isDraft, isEventRelatedToAnnotation, isFunction, isHighlight, isImageMimeType, isNull, isNullish, isNumber, isObject, isPdfMimeType, isReference, isResolvedReference, isResourceId, isStoredEvent, isString, isStubReference, isTag, isTextMimeType, isUndefined, isValidEmail, isValidPlatformType, jobId, loadTomlConfig, mcpToken, normalizeCoordinates, normalizeText, parseEnvironment, parseSvgSelector, refreshToken, resourceAnnotationUri, resourceId, resourceUri, scaleSvgToNative, searchQuery, serializePerKey, setBusLogTraceIdProvider, softwareToAgent, userDID, userId, userToAgent, userToDid, validateAndCorrectOffsets, validateData, validateEnvironment, validateSvgMarkup, verifyPosition };
1947
1969
  //# sourceMappingURL=index.js.map
1948
1970
  //# sourceMappingURL=index.js.map