@opengeni/contracts 2.15.2 → 3.0.0-canary.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/atlassian.js +10 -9
  2. package/dist/{chunk-NPYLOZAP.js → chunk-5LYFSZ7O.js} +12 -12
  3. package/dist/{chunk-6TCVR53X.js → chunk-O5LEQHDM.js} +2 -2
  4. package/dist/{chunk-QP3BIGSC.js → chunk-OO4AEMQB.js} +7633 -7650
  5. package/dist/chunk-OO4AEMQB.js.map +1 -0
  6. package/dist/chunk-P3HLDT77.js +59 -0
  7. package/dist/chunk-P3HLDT77.js.map +1 -0
  8. package/dist/chunk-SSWEWU3V.js +348 -0
  9. package/dist/chunk-SSWEWU3V.js.map +1 -0
  10. package/dist/chunk-TEMFILR7.js +143 -0
  11. package/dist/chunk-TEMFILR7.js.map +1 -0
  12. package/dist/connect.d.ts +325 -0
  13. package/dist/connect.js +182 -0
  14. package/dist/connect.js.map +1 -0
  15. package/dist/connection-authority.js +28 -334
  16. package/dist/connection-authority.js.map +1 -1
  17. package/dist/editable-artifact-codec-registry.js +2 -2
  18. package/dist/editable-artifact-live.js +2 -2
  19. package/dist/editable-artifact-serialized-commit.js +3 -3
  20. package/dist/editable-artifacts.js +24 -24
  21. package/dist/external-identities.d.ts +620 -0
  22. package/dist/external-identities.js +34 -0
  23. package/dist/external-identities.js.map +1 -0
  24. package/dist/google-drive.js +12 -11
  25. package/dist/google-drive.js.map +1 -1
  26. package/dist/host-mcp-bindings.d.ts +297 -0
  27. package/dist/host-mcp-bindings.js +195 -0
  28. package/dist/host-mcp-bindings.js.map +1 -0
  29. package/dist/index.d.ts +149 -71
  30. package/dist/index.js +85 -81
  31. package/dist/personal-github.js +10 -9
  32. package/dist/personal-github.js.map +1 -1
  33. package/package.json +13 -1
  34. package/src/connect.ts +202 -0
  35. package/src/external-identities.ts +213 -0
  36. package/src/host-mcp-bindings.ts +226 -0
  37. package/src/index.ts +158 -68
  38. package/dist/chunk-QP3BIGSC.js.map +0 -1
  39. /package/dist/{chunk-NPYLOZAP.js.map → chunk-5LYFSZ7O.js.map} +0 -0
  40. /package/dist/{chunk-6TCVR53X.js.map → chunk-O5LEQHDM.js.map} +0 -0
package/dist/index.js CHANGED
@@ -610,6 +610,7 @@ import {
610
610
  HostExportCursor,
611
611
  HostExportInitiator,
612
612
  HostExportInitiatorContext,
613
+ HostMcpCreateSelections,
613
614
  HostSessionEvent,
614
615
  HostUsageEvent,
615
616
  HostUsageExport,
@@ -965,7 +966,6 @@ import {
965
966
  PackInstallationStatus,
966
967
  PackRigResolution,
967
968
  PackUninstallPreview,
968
- Permission,
969
969
  PersonalResourceAttachmentIntent,
970
970
  PersonalResourceAttachmentSummary,
971
971
  PersonalResourceRetentionMode,
@@ -1126,8 +1126,6 @@ import {
1126
1126
  SESSION_AUTHORIZATION_LIST_SCOPE_MAX_IDS,
1127
1127
  SESSION_EFFECTIVE_TOOL_POLICY_ID_LIMIT,
1128
1128
  SESSION_EFFECTIVE_TOOL_POLICY_ID_MAX_LENGTH,
1129
- SESSION_END_USER_ID_MAX_CHARS,
1130
- SESSION_END_USER_SOURCE_MAX_CHARS,
1131
1129
  SESSION_EVENT_CLIENT_EVENT_ID_MAX_BYTES,
1132
1130
  SESSION_EVENT_DUPLICATE_REASON_MAX_BYTES,
1133
1131
  SESSION_EVENT_ENVELOPE_MAX_BYTES,
@@ -1213,7 +1211,6 @@ import {
1213
1211
  SessionControlResponse,
1214
1212
  SessionControlState,
1215
1213
  SessionEffectiveToolPolicy,
1216
- SessionEndUser,
1217
1214
  SessionEvent,
1218
1215
  SessionEventLatestClass,
1219
1216
  SessionEventPayloadMode,
@@ -1259,6 +1256,7 @@ import {
1259
1256
  SessionRealtimeModel,
1260
1257
  SessionRealtimeMutationResponse,
1261
1258
  SessionRealtimeState,
1259
+ SessionScopeSubjectId,
1262
1260
  SessionSkill,
1263
1261
  SessionSkills,
1264
1262
  SessionSpawnDenial,
@@ -1747,6 +1745,7 @@ import {
1747
1745
  bundledSkillSelectionFromMetadata,
1748
1746
  canonicalCodexFleetReplayJsonV1,
1749
1747
  canonicalModalCheckpointProviderBinding,
1748
+ canonicalSkillReviewQuestion,
1750
1749
  canonicalizeSlackTaskPolicy,
1751
1750
  canonicalizeWorkspaceLearningSourceOverrides,
1752
1751
  capabilityCatalogItemIsTrustedForExposure,
@@ -1847,6 +1846,7 @@ import {
1847
1846
  signStreamToken,
1848
1847
  skillReviewHumanInput,
1849
1848
  stableJson,
1849
+ storedSessionMemoryScope,
1850
1850
  toolResultSpillFilename,
1851
1851
  toolResultSpillSandboxPath,
1852
1852
  turnExecutionPolicyAuditMetadata,
@@ -1864,7 +1864,7 @@ import {
1864
1864
  workspaceLearningPolicyRouterContext,
1865
1865
  workspaceLearningSourceKey,
1866
1866
  workspaceSlackReactionChannelAllowed
1867
- } from "./chunk-QP3BIGSC.js";
1867
+ } from "./chunk-OO4AEMQB.js";
1868
1868
  import {
1869
1869
  CONNECTOR_ATTACHMENT_FILENAME_MAX_UTF8_BYTES,
1870
1870
  CONNECTOR_ATTACHMENT_MAX_BYTES,
@@ -1896,7 +1896,7 @@ import {
1896
1896
  assertCanonicalEditableArtifactSerializedCommit,
1897
1897
  decodeEditableArtifactSerializedCommit,
1898
1898
  encodeEditableArtifactSerializedCommit
1899
- } from "./chunk-6TCVR53X.js";
1899
+ } from "./chunk-O5LEQHDM.js";
1900
1900
  import {
1901
1901
  WORKSPACE_XAI_PROVIDER_ACCOUNT_AUTHORITY_SNAPSHOT_V1,
1902
1902
  XaiProviderAccountAuthoritySnapshotV1
@@ -1924,6 +1924,29 @@ import {
1924
1924
  MAX_COMMITTED_TRANSACTION_OPERATIONS,
1925
1925
  decodeCommittedTransactionSummary
1926
1926
  } from "./chunk-3SIZGL3O.js";
1927
+ import {
1928
+ EDITABLE_ARTIFACT_COMMAND_MAX_BYTES,
1929
+ EDITABLE_ARTIFACT_INTENT_MAX_BYTES,
1930
+ EDITABLE_ARTIFACT_INTENT_MAX_CAUSAL_ACTORS,
1931
+ EDITABLE_ARTIFACT_INTENT_MAX_UNDO_TARGETS,
1932
+ EDITABLE_ARTIFACT_INTENT_PROTOCOL_VERSION,
1933
+ EDITABLE_ARTIFACT_INTENT_VERSION,
1934
+ EDITABLE_ARTIFACT_KERNEL_VERSION_MAX_BYTES,
1935
+ EDITABLE_ARTIFACT_PRODUCT_MAX_SNAPSHOT_BYTES,
1936
+ assertEditableArtifactRequestHash,
1937
+ decodeEditableArtifactMutationIntent,
1938
+ encodeEditableArtifactMutationIntent,
1939
+ hashEditableArtifactMutationIntent,
1940
+ hashEditableArtifactMutationIntentBytes
1941
+ } from "./chunk-NVJMJWLL.js";
1942
+ import {
1943
+ EDITABLE_ARTIFACT_CAUSAL_FRONTIER_MAX_BYTES,
1944
+ EDITABLE_ARTIFACT_CAUSAL_FRONTIER_MAX_REPLICAS,
1945
+ EDITABLE_ARTIFACT_CAUSAL_FRONTIER_VERSION,
1946
+ assertCanonicalEditableArtifactCausalFrontierBytes,
1947
+ decodeEditableArtifactCausalFrontier,
1948
+ encodeEditableArtifactCausalFrontier
1949
+ } from "./chunk-YRKRZ6OF.js";
1927
1950
  import {
1928
1951
  CanonicalHumanBindingOperationRequest,
1929
1952
  CanonicalHumanIdentityMutationOutcome,
@@ -2005,59 +2028,34 @@ import {
2005
2028
  OrganizationRecoveryUnavailableReason,
2006
2029
  StartOrganizationRecoveryOperationRequest
2007
2030
  } from "./chunk-BCS7WHCK.js";
2008
- import {
2009
- SiteSessionPathError,
2010
- siteSessionPath
2011
- } from "./chunk-UGTBTPTQ.js";
2012
- import {
2013
- ConnectorDocumentDestination,
2014
- ConnectorDocumentDestinationAuthority,
2015
- ConnectorDocumentDestinationSelection,
2016
- bindConnectorDocumentDestination,
2017
- connectorDestinationDocumentAuthority,
2018
- connectorDocumentDestinationCollectionId,
2019
- legacyWorkspaceConnectorDocumentDestination,
2020
- resolveConnectorDocumentDestination
2021
- } from "./chunk-WYBDERIY.js";
2022
- import {
2023
- AUTOMATIC_SESSION_TITLE_FALLBACK,
2024
- AUTOMATIC_SESSION_TITLE_MAX_GRAPHEMES,
2025
- SESSION_TITLE_MAX_CHARACTERS,
2026
- boundAutomaticSessionTitle,
2027
- containsSensitiveAutomaticSessionTitleValue,
2028
- deriveAutomaticSessionTitlePreview,
2029
- deriveSessionDisplayTitle,
2030
- normalizeAutomaticSessionTitle,
2031
- sessionTitleIsPending
2032
- } from "./chunk-7ABONTXE.js";
2033
- import {
2034
- EDITABLE_ARTIFACT_COMMAND_MAX_BYTES,
2035
- EDITABLE_ARTIFACT_INTENT_MAX_BYTES,
2036
- EDITABLE_ARTIFACT_INTENT_MAX_CAUSAL_ACTORS,
2037
- EDITABLE_ARTIFACT_INTENT_MAX_UNDO_TARGETS,
2038
- EDITABLE_ARTIFACT_INTENT_PROTOCOL_VERSION,
2039
- EDITABLE_ARTIFACT_INTENT_VERSION,
2040
- EDITABLE_ARTIFACT_KERNEL_VERSION_MAX_BYTES,
2041
- EDITABLE_ARTIFACT_PRODUCT_MAX_SNAPSHOT_BYTES,
2042
- assertEditableArtifactRequestHash,
2043
- decodeEditableArtifactMutationIntent,
2044
- encodeEditableArtifactMutationIntent,
2045
- hashEditableArtifactMutationIntent,
2046
- hashEditableArtifactMutationIntentBytes
2047
- } from "./chunk-NVJMJWLL.js";
2048
- import {
2049
- EDITABLE_ARTIFACT_CAUSAL_FRONTIER_MAX_BYTES,
2050
- EDITABLE_ARTIFACT_CAUSAL_FRONTIER_MAX_REPLICAS,
2051
- EDITABLE_ARTIFACT_CAUSAL_FRONTIER_VERSION,
2052
- assertCanonicalEditableArtifactCausalFrontierBytes,
2053
- decodeEditableArtifactCausalFrontier,
2054
- encodeEditableArtifactCausalFrontier
2055
- } from "./chunk-YRKRZ6OF.js";
2056
2031
  import {
2057
2032
  EDITABLE_ARTIFACT_CODEC_REGISTRY,
2058
2033
  currentEditableArtifactCompatibility,
2059
2034
  editableArtifactCodecFor
2060
- } from "./chunk-NPYLOZAP.js";
2035
+ } from "./chunk-5LYFSZ7O.js";
2036
+ import {
2037
+ SPREADSHEET_ARTIFACT_METADATA_MAX_SHEETS,
2038
+ SPREADSHEET_ARTIFACT_METADATA_MIN_RESPONSE_BYTES,
2039
+ SPREADSHEET_ARTIFACT_PROJECTION_MAX_BYTES,
2040
+ SPREADSHEET_ARTIFACT_PROJECTION_MAX_STRING_BYTES,
2041
+ SPREADSHEET_ARTIFACT_QUERY_MAX_BYTES,
2042
+ SPREADSHEET_ARTIFACT_QUERY_VERSION,
2043
+ SPREADSHEET_ARTIFACT_VIEWPORT_MAX_AREA,
2044
+ SPREADSHEET_ARTIFACT_VIEWPORT_MAX_CELLS,
2045
+ SPREADSHEET_ARTIFACT_VIEWPORT_MIN_RESPONSE_BYTES,
2046
+ assertCanonicalSpreadsheetArtifactKernelProjectionBytes,
2047
+ assertCanonicalSpreadsheetArtifactKernelQueryBytes,
2048
+ decodeSpreadsheetArtifactKernelProjection,
2049
+ decodeSpreadsheetArtifactKernelQuery,
2050
+ decodeSpreadsheetMetadataKernelProjection,
2051
+ decodeSpreadsheetViewportKernelProjection,
2052
+ encodeSpreadsheetArtifactKernelProjection,
2053
+ encodeSpreadsheetArtifactKernelQuery,
2054
+ encodeSpreadsheetMetadataKernelProjection,
2055
+ encodeSpreadsheetMetadataKernelQuery,
2056
+ encodeSpreadsheetViewportKernelProjection,
2057
+ encodeSpreadsheetViewportKernelQuery
2058
+ } from "./chunk-Y3KNXVTD.js";
2061
2059
  import {
2062
2060
  PRESENTATION_ARTIFACT_COMMAND_MAX_BYTES,
2063
2061
  PRESENTATION_ARTIFACT_COMMAND_MAX_COMMANDS,
@@ -2090,29 +2088,6 @@ import {
2090
2088
  encodePresentationArtifactQuery,
2091
2089
  encodePresentationArtifactQueryResponse
2092
2090
  } from "./chunk-D2HKF2EF.js";
2093
- import {
2094
- SPREADSHEET_ARTIFACT_METADATA_MAX_SHEETS,
2095
- SPREADSHEET_ARTIFACT_METADATA_MIN_RESPONSE_BYTES,
2096
- SPREADSHEET_ARTIFACT_PROJECTION_MAX_BYTES,
2097
- SPREADSHEET_ARTIFACT_PROJECTION_MAX_STRING_BYTES,
2098
- SPREADSHEET_ARTIFACT_QUERY_MAX_BYTES,
2099
- SPREADSHEET_ARTIFACT_QUERY_VERSION,
2100
- SPREADSHEET_ARTIFACT_VIEWPORT_MAX_AREA,
2101
- SPREADSHEET_ARTIFACT_VIEWPORT_MAX_CELLS,
2102
- SPREADSHEET_ARTIFACT_VIEWPORT_MIN_RESPONSE_BYTES,
2103
- assertCanonicalSpreadsheetArtifactKernelProjectionBytes,
2104
- assertCanonicalSpreadsheetArtifactKernelQueryBytes,
2105
- decodeSpreadsheetArtifactKernelProjection,
2106
- decodeSpreadsheetArtifactKernelQuery,
2107
- decodeSpreadsheetMetadataKernelProjection,
2108
- decodeSpreadsheetViewportKernelProjection,
2109
- encodeSpreadsheetArtifactKernelProjection,
2110
- encodeSpreadsheetArtifactKernelQuery,
2111
- encodeSpreadsheetMetadataKernelProjection,
2112
- encodeSpreadsheetMetadataKernelQuery,
2113
- encodeSpreadsheetViewportKernelProjection,
2114
- encodeSpreadsheetViewportKernelQuery
2115
- } from "./chunk-Y3KNXVTD.js";
2116
2091
  import {
2117
2092
  SPREADSHEET_ARTIFACT_COMMAND_MAX_BYTES,
2118
2093
  SPREADSHEET_ARTIFACT_COMMAND_MAX_CELLS,
@@ -2163,6 +2138,34 @@ import {
2163
2138
  SPREADSHEET_ARTIFACT_MODEL_SCHEMA_VERSION,
2164
2139
  SPREADSHEET_COLLABORATION_SNAPSHOT_VERSION
2165
2140
  } from "./chunk-PX3VCKAU.js";
2141
+ import {
2142
+ SiteSessionPathError,
2143
+ siteSessionPath
2144
+ } from "./chunk-UGTBTPTQ.js";
2145
+ import {
2146
+ ConnectorDocumentDestination,
2147
+ ConnectorDocumentDestinationAuthority,
2148
+ ConnectorDocumentDestinationSelection,
2149
+ bindConnectorDocumentDestination,
2150
+ connectorDestinationDocumentAuthority,
2151
+ connectorDocumentDestinationCollectionId,
2152
+ legacyWorkspaceConnectorDocumentDestination,
2153
+ resolveConnectorDocumentDestination
2154
+ } from "./chunk-WYBDERIY.js";
2155
+ import {
2156
+ Permission
2157
+ } from "./chunk-P3HLDT77.js";
2158
+ import {
2159
+ AUTOMATIC_SESSION_TITLE_FALLBACK,
2160
+ AUTOMATIC_SESSION_TITLE_MAX_GRAPHEMES,
2161
+ SESSION_TITLE_MAX_CHARACTERS,
2162
+ boundAutomaticSessionTitle,
2163
+ containsSensitiveAutomaticSessionTitleValue,
2164
+ deriveAutomaticSessionTitlePreview,
2165
+ deriveSessionDisplayTitle,
2166
+ normalizeAutomaticSessionTitle,
2167
+ sessionTitleIsPending
2168
+ } from "./chunk-7ABONTXE.js";
2166
2169
  export {
2167
2170
  AGENT_AUTHORED_COMPANY_PROFILE_CONTENT_MAX_UTF8_BYTES,
2168
2171
  AGENT_AUTHORED_COMPANY_PROFILE_ENTRY_MAX_CHARS,
@@ -2858,6 +2861,7 @@ export {
2858
2861
  HostExportCursor,
2859
2862
  HostExportInitiator,
2860
2863
  HostExportInitiatorContext,
2864
+ HostMcpCreateSelections,
2861
2865
  HostSessionEvent,
2862
2866
  HostUsageEvent,
2863
2867
  HostUsageExport,
@@ -3434,8 +3438,6 @@ export {
3434
3438
  SESSION_AUTHORIZATION_LIST_SCOPE_MAX_IDS,
3435
3439
  SESSION_EFFECTIVE_TOOL_POLICY_ID_LIMIT,
3436
3440
  SESSION_EFFECTIVE_TOOL_POLICY_ID_MAX_LENGTH,
3437
- SESSION_END_USER_ID_MAX_CHARS,
3438
- SESSION_END_USER_SOURCE_MAX_CHARS,
3439
3441
  SESSION_EVENT_CLIENT_EVENT_ID_MAX_BYTES,
3440
3442
  SESSION_EVENT_DUPLICATE_REASON_MAX_BYTES,
3441
3443
  SESSION_EVENT_ENVELOPE_MAX_BYTES,
@@ -3539,7 +3541,6 @@ export {
3539
3541
  SessionControlResponse,
3540
3542
  SessionControlState,
3541
3543
  SessionEffectiveToolPolicy,
3542
- SessionEndUser,
3543
3544
  SessionEvent,
3544
3545
  SessionEventLatestClass,
3545
3546
  SessionEventPayloadMode,
@@ -3585,6 +3586,7 @@ export {
3585
3586
  SessionRealtimeModel,
3586
3587
  SessionRealtimeMutationResponse,
3587
3588
  SessionRealtimeState,
3589
+ SessionScopeSubjectId,
3588
3590
  SessionSkill,
3589
3591
  SessionSkills,
3590
3592
  SessionSpawnDenial,
@@ -4113,6 +4115,7 @@ export {
4113
4115
  bundledSkillSelectionFromMetadata,
4114
4116
  canonicalCodexFleetReplayJsonV1,
4115
4117
  canonicalModalCheckpointProviderBinding,
4118
+ canonicalSkillReviewQuestion,
4116
4119
  canonicalizeSlackTaskPolicy,
4117
4120
  canonicalizeWorkspaceLearningSourceOverrides,
4118
4121
  capabilityCatalogItemIsTrustedForExposure,
@@ -4270,6 +4273,7 @@ export {
4270
4273
  skillReviewHumanInput,
4271
4274
  spreadsheetSheetId,
4272
4275
  stableJson,
4276
+ storedSessionMemoryScope,
4273
4277
  toolResultSpillFilename,
4274
4278
  toolResultSpillSandboxPath,
4275
4279
  turnExecutionPolicyAuditMetadata,
@@ -1,26 +1,27 @@
1
1
  import {
2
2
  ConnectionMetadata
3
- } from "./chunk-QP3BIGSC.js";
3
+ } from "./chunk-OO4AEMQB.js";
4
4
  import "./chunk-YBW5JSA3.js";
5
- import "./chunk-6TCVR53X.js";
5
+ import "./chunk-O5LEQHDM.js";
6
6
  import "./chunk-GRG7PHWQ.js";
7
7
  import "./chunk-MRWYRAS5.js";
8
8
  import "./chunk-3SIZGL3O.js";
9
+ import "./chunk-NVJMJWLL.js";
10
+ import "./chunk-YRKRZ6OF.js";
9
11
  import "./chunk-JUFK3T4Q.js";
10
12
  import "./chunk-M5ZGRVIQ.js";
11
13
  import "./chunk-BCS7WHCK.js";
12
- import "./chunk-UGTBTPTQ.js";
13
- import "./chunk-WYBDERIY.js";
14
- import "./chunk-7ABONTXE.js";
15
- import "./chunk-NVJMJWLL.js";
16
- import "./chunk-YRKRZ6OF.js";
17
- import "./chunk-NPYLOZAP.js";
18
- import "./chunk-D2HKF2EF.js";
14
+ import "./chunk-5LYFSZ7O.js";
19
15
  import "./chunk-Y3KNXVTD.js";
16
+ import "./chunk-D2HKF2EF.js";
20
17
  import "./chunk-TXTQIYCV.js";
21
18
  import "./chunk-RIY7GYQS.js";
22
19
  import "./chunk-MYBZRDTY.js";
23
20
  import "./chunk-PX3VCKAU.js";
21
+ import "./chunk-UGTBTPTQ.js";
22
+ import "./chunk-WYBDERIY.js";
23
+ import "./chunk-P3HLDT77.js";
24
+ import "./chunk-7ABONTXE.js";
24
25
 
25
26
  // src/personal-github.ts
26
27
  import { z } from "zod";
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/personal-github.ts"],"sourcesContent":["import { z } from \"zod\";\n\nimport { ConnectionMetadata } from \"./index\";\n\nexport const PERSONAL_GITHUB_PROVIDER_DOMAIN = \"github.com\" as const;\nexport const PERSONAL_GITHUB_PROVIDER_FAMILY = \"github\" as const;\nexport const PERSONAL_GITHUB_CREDENTIAL_ROLE = \"opengeni_github_personal\" as const;\nexport const PERSONAL_GITHUB_CONNECTION_SURFACE_ID = \"github:personal\" as const;\nexport const PERSONAL_GITHUB_REQUESTED_SCOPES = [\"repo\"] as const;\nexport const PERSONAL_GITHUB_AUTHORIZATION_URL =\n \"https://github.com/login/oauth/authorize\" as const;\nexport const PERSONAL_GITHUB_TOKEN_URL = \"https://github.com/login/oauth/access_token\" as const;\nexport const PERSONAL_GITHUB_USER_URL = \"https://api.github.com/user\" as const;\nexport const PERSONAL_GITHUB_API_ORIGIN = \"https://api.github.com\" as const;\nexport const PERSONAL_GITHUB_REPOSITORY_CATALOG_MAX = 100 as const;\n\nexport const PersonalGitHubRepositoryId = z.string().regex(/^[1-9]\\d*$/u);\nexport type PersonalGitHubRepositoryId = z.infer<typeof PersonalGitHubRepositoryId>;\n\nexport const PersonalGitHubRepositoryAccess = z.enum([\"read\", \"write\"]);\nexport type PersonalGitHubRepositoryAccess = z.infer<typeof PersonalGitHubRepositoryAccess>;\n\nexport const PersonalGitHubRepositoryPermissions = z\n .object({\n pull: z.boolean(),\n push: z.boolean(),\n admin: z.boolean(),\n maintain: z.boolean(),\n triage: z.boolean(),\n })\n .strict();\nexport type PersonalGitHubRepositoryPermissions = z.infer<\n typeof PersonalGitHubRepositoryPermissions\n>;\n\nexport const PersonalGitHubRepositoryVisibility = z.enum([\"public\", \"private\", \"internal\"]);\nexport type PersonalGitHubRepositoryVisibility = z.infer<typeof PersonalGitHubRepositoryVisibility>;\n\nconst PersonalGitHubRepositoryFullName = z\n .string()\n .min(3)\n .max(140)\n .regex(/^[A-Za-z0-9](?:[A-Za-z0-9-]{0,38})\\/[A-Za-z0-9_.-]{1,100}$/u);\n\nexport function canonicalPersonalGitHubRepositoryUrl(fullName: string): string {\n return `https://github.com/${fullName}`;\n}\n\n/** A bounded, credential-free projection verified directly against GitHub. */\nexport const PersonalGitHubRepository = z\n .object({\n repositoryId: PersonalGitHubRepositoryId,\n fullName: PersonalGitHubRepositoryFullName,\n canonicalUrl: z.string().url().max(512),\n defaultBranch: z.string().min(1).max(255),\n visibility: PersonalGitHubRepositoryVisibility,\n private: z.boolean(),\n archived: z.boolean(),\n disabled: z.boolean(),\n permissions: PersonalGitHubRepositoryPermissions,\n })\n .strict()\n .superRefine((repository, context) => {\n if (repository.canonicalUrl !== canonicalPersonalGitHubRepositoryUrl(repository.fullName)) {\n context.addIssue({\n code: \"custom\",\n path: [\"canonicalUrl\"],\n message: \"canonicalUrl must be derived from fullName\",\n });\n }\n if (repository.private !== (repository.visibility === \"private\")) {\n context.addIssue({\n code: \"custom\",\n path: [\"private\"],\n message: \"private must agree with visibility\",\n });\n }\n });\nexport type PersonalGitHubRepository = z.infer<typeof PersonalGitHubRepository>;\n\nexport const PersonalGitHubSelectedRepository = PersonalGitHubRepository.safeExtend({\n selectedAccess: PersonalGitHubRepositoryAccess,\n selectionGeneration: z.number().int().positive(),\n selectedAt: z.string().datetime({ offset: true }),\n lastVerifiedAt: z.string().datetime({ offset: true }),\n}).strict();\nexport type PersonalGitHubSelectedRepository = z.infer<typeof PersonalGitHubSelectedRepository>;\n\nexport const PersonalGitHubRepositorySelectionState = z\n .object({\n connectionAuthorityGeneration: z.number().int().positive(),\n credentialBindingId: z.string().uuid(),\n providerPrincipalId: PersonalGitHubRepositoryId,\n selectionGeneration: z.number().int().nonnegative(),\n repositories: z\n .array(PersonalGitHubSelectedRepository)\n .max(PERSONAL_GITHUB_REPOSITORY_CATALOG_MAX),\n })\n .strict();\nexport type PersonalGitHubRepositorySelectionState = z.infer<\n typeof PersonalGitHubRepositorySelectionState\n>;\n\nexport const ListPersonalGitHubRepositoriesQuery = z\n .object({\n cursor: z.coerce.number().int().positive().max(10_000).default(1),\n limit: z.coerce.number().int().min(1).max(PERSONAL_GITHUB_REPOSITORY_CATALOG_MAX).default(50),\n })\n .strict();\nexport type ListPersonalGitHubRepositoriesQuery = z.infer<\n typeof ListPersonalGitHubRepositoriesQuery\n>;\n\nexport const PersonalGitHubRepositoryCatalogItem = PersonalGitHubRepository.safeExtend({\n selectedAccess: PersonalGitHubRepositoryAccess.nullable(),\n}).strict();\nexport type PersonalGitHubRepositoryCatalogItem = z.infer<\n typeof PersonalGitHubRepositoryCatalogItem\n>;\n\nexport const ListPersonalGitHubRepositoriesResponse = z\n .object({\n repositories: z\n .array(PersonalGitHubRepositoryCatalogItem)\n .max(PERSONAL_GITHUB_REPOSITORY_CATALOG_MAX),\n nextCursor: z.number().int().positive().nullable(),\n selection: PersonalGitHubRepositorySelectionState,\n })\n .strict();\nexport type ListPersonalGitHubRepositoriesResponse = z.infer<\n typeof ListPersonalGitHubRepositoriesResponse\n>;\n\nexport const PersonalGitHubRepositorySelectionInput = z\n .object({\n repositoryId: PersonalGitHubRepositoryId,\n fullName: PersonalGitHubRepositoryFullName,\n access: PersonalGitHubRepositoryAccess,\n })\n .strict();\nexport type PersonalGitHubRepositorySelectionInput = z.infer<\n typeof PersonalGitHubRepositorySelectionInput\n>;\n\nexport const ReplacePersonalGitHubRepositorySelectionsRequest = z\n .object({\n expectedConnectionAuthorityGeneration: z.number().int().positive(),\n expectedSelectionGeneration: z.number().int().nonnegative(),\n idempotencyKey: z.string().trim().min(1).max(200),\n repositories: z\n .array(PersonalGitHubRepositorySelectionInput)\n .max(PERSONAL_GITHUB_REPOSITORY_CATALOG_MAX),\n })\n .strict()\n .superRefine((request, context) => {\n const repositoryIds = new Set<string>();\n const fullNames = new Set<string>();\n request.repositories.forEach((repository, index) => {\n const normalizedFullName = repository.fullName.toLowerCase();\n if (repositoryIds.has(repository.repositoryId)) {\n context.addIssue({\n code: \"custom\",\n path: [\"repositories\", index, \"repositoryId\"],\n message: \"repositoryId must be unique\",\n });\n }\n if (fullNames.has(normalizedFullName)) {\n context.addIssue({\n code: \"custom\",\n path: [\"repositories\", index, \"fullName\"],\n message: \"fullName must be unique\",\n });\n }\n repositoryIds.add(repository.repositoryId);\n fullNames.add(normalizedFullName);\n });\n });\nexport type ReplacePersonalGitHubRepositorySelectionsRequest = z.infer<\n typeof ReplacePersonalGitHubRepositorySelectionsRequest\n>;\n\nexport const VerifyPersonalGitHubRepositorySelectionsRequest = z\n .object({\n expectedConnectionAuthorityGeneration: z.number().int().positive(),\n expectedSelectionGeneration: z.number().int().nonnegative(),\n idempotencyKey: z.string().trim().min(1).max(200),\n })\n .strict();\nexport type VerifyPersonalGitHubRepositorySelectionsRequest = z.infer<\n typeof VerifyPersonalGitHubRepositorySelectionsRequest\n>;\n\n/**\n * Owner-visible, credential-free metadata for one dedicated personal GitHub\n * OAuth connection. Repository selections are a separate authority and never\n * live in this credential record.\n */\nexport const PersonalGitHubConnectionMetadata = z\n .object({\n credentialRole: z.literal(PERSONAL_GITHUB_CREDENTIAL_ROLE),\n providerFamily: z.literal(PERSONAL_GITHUB_PROVIDER_FAMILY),\n providerPrincipalId: z.string().regex(/^\\d+$/u),\n githubUserId: z.string().regex(/^\\d+$/u),\n githubLogin: z.string().min(1).max(100),\n oauthEnvironment: z.string().min(1).max(128),\n oauthClientMarker: z.string().regex(/^[a-f0-9]{32}$/u),\n credentialBindingId: z.string().uuid(),\n connectedAt: z.string().datetime({ offset: true }),\n lastVerifiedAt: z.string().datetime({ offset: true }),\n disconnectedAt: z.string().datetime({ offset: true }).nullable().optional(),\n refreshTokenExpiresAt: z.string().datetime({ offset: true }).nullable().optional(),\n })\n .passthrough();\nexport type PersonalGitHubConnectionMetadata = z.infer<typeof PersonalGitHubConnectionMetadata>;\n\nexport const PersonalGitHubOAuthStartRequest = z\n .object({\n /** Existing exact connection generation to re-authorize in place. */\n connectionId: z.string().uuid().optional(),\n /** Same-workspace UI path restored after the callback. */\n returnPath: z.string().min(1).max(2048).optional(),\n })\n .strict();\nexport type PersonalGitHubOAuthStartRequest = z.infer<typeof PersonalGitHubOAuthStartRequest>;\n\nexport const PersonalGitHubOAuthStartResponse = z\n .object({\n authorizationUrl: z.string().url(),\n expiresAt: z.string().datetime({ offset: true }),\n })\n .strict();\nexport type PersonalGitHubOAuthStartResponse = z.infer<typeof PersonalGitHubOAuthStartResponse>;\n\nexport const PersonalGitHubConnectionStatusResponse = z\n .object({\n enabled: z.boolean(),\n connection: ConnectionMetadata.nullable(),\n reviewUrl: z.string().url().nullable(),\n })\n .strict();\nexport type PersonalGitHubConnectionStatusResponse = z.infer<\n typeof PersonalGitHubConnectionStatusResponse\n>;\n\nexport const PersonalGitHubDisconnectRequest = z\n .object({\n expectedVersion: z.number().int().positive(),\n idempotencyKey: z.string().trim().min(1).max(200),\n })\n .strict();\nexport type PersonalGitHubDisconnectRequest = z.infer<typeof PersonalGitHubDisconnectRequest>;\n\nexport function isPersonalGitHubConnection(\n connection: Pick<z.infer<typeof ConnectionMetadata>, \"providerDomain\" | \"kind\" | \"metadata\">,\n): boolean {\n return (\n connection.providerDomain.toLowerCase() === PERSONAL_GITHUB_PROVIDER_DOMAIN &&\n connection.kind === \"oauth2\" &&\n PersonalGitHubConnectionMetadata.safeParse(connection.metadata).success\n );\n}\n\nexport function hasReservedPersonalGitHubMetadata(\n metadata: Record<string, unknown> | undefined,\n): boolean {\n return metadata?.credentialRole === PERSONAL_GITHUB_CREDENTIAL_ROLE;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,SAAS;AAIX,IAAM,kCAAkC;AACxC,IAAM,kCAAkC;AACxC,IAAM,kCAAkC;AACxC,IAAM,wCAAwC;AAC9C,IAAM,mCAAmC,CAAC,MAAM;AAChD,IAAM,oCACX;AACK,IAAM,4BAA4B;AAClC,IAAM,2BAA2B;AACjC,IAAM,6BAA6B;AACnC,IAAM,yCAAyC;AAE/C,IAAM,6BAA6B,EAAE,OAAO,EAAE,MAAM,aAAa;AAGjE,IAAM,iCAAiC,EAAE,KAAK,CAAC,QAAQ,OAAO,CAAC;AAG/D,IAAM,sCAAsC,EAChD,OAAO;AAAA,EACN,MAAM,EAAE,QAAQ;AAAA,EAChB,MAAM,EAAE,QAAQ;AAAA,EAChB,OAAO,EAAE,QAAQ;AAAA,EACjB,UAAU,EAAE,QAAQ;AAAA,EACpB,QAAQ,EAAE,QAAQ;AACpB,CAAC,EACA,OAAO;AAKH,IAAM,qCAAqC,EAAE,KAAK,CAAC,UAAU,WAAW,UAAU,CAAC;AAG1F,IAAM,mCAAmC,EACtC,OAAO,EACP,IAAI,CAAC,EACL,IAAI,GAAG,EACP,MAAM,6DAA6D;AAE/D,SAAS,qCAAqC,UAA0B;AAC7E,SAAO,sBAAsB,QAAQ;AACvC;AAGO,IAAM,2BAA2B,EACrC,OAAO;AAAA,EACN,cAAc;AAAA,EACd,UAAU;AAAA,EACV,cAAc,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,GAAG;AAAA,EACtC,eAAe,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,IAAI,GAAG;AAAA,EACxC,YAAY;AAAA,EACZ,SAAS,EAAE,QAAQ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,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS;AAAA;AAAA,EAEzC,YAAY,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,IAAI,IAAI,EAAE,SAAS;AACnD,CAAC,EACA,OAAO;AAGH,IAAM,mCAAmC,EAC7C,OAAO;AAAA,EACN,kBAAkB,EAAE,OAAO,EAAE,IAAI;AAAA,EACjC,WAAW,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,KAAK,CAAC;AACjD,CAAC,EACA,OAAO;AAGH,IAAM,yCAAyC,EACnD,OAAO;AAAA,EACN,SAAS,EAAE,QAAQ;AAAA,EACnB,YAAY,mBAAmB,SAAS;AAAA,EACxC,WAAW,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS;AACvC,CAAC,EACA,OAAO;AAKH,IAAM,kCAAkC,EAC5C,OAAO;AAAA,EACN,iBAAiB,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS;AAAA,EAC3C,gBAAgB,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,IAAI,GAAG;AAClD,CAAC,EACA,OAAO;AAGH,SAAS,2BACd,YACS;AACT,SACE,WAAW,eAAe,YAAY,MAAM,mCAC5C,WAAW,SAAS,YACpB,iCAAiC,UAAU,WAAW,QAAQ,EAAE;AAEpE;AAEO,SAAS,kCACd,UACS;AACT,SAAO,UAAU,mBAAmB;AACtC;","names":[]}
1
+ {"version":3,"sources":["../src/personal-github.ts"],"sourcesContent":["import { z } from \"zod\";\n\nimport { ConnectionMetadata } from \"./index\";\n\nexport const PERSONAL_GITHUB_PROVIDER_DOMAIN = \"github.com\" as const;\nexport const PERSONAL_GITHUB_PROVIDER_FAMILY = \"github\" as const;\nexport const PERSONAL_GITHUB_CREDENTIAL_ROLE = \"opengeni_github_personal\" as const;\nexport const PERSONAL_GITHUB_CONNECTION_SURFACE_ID = \"github:personal\" as const;\nexport const PERSONAL_GITHUB_REQUESTED_SCOPES = [\"repo\"] as const;\nexport const PERSONAL_GITHUB_AUTHORIZATION_URL =\n \"https://github.com/login/oauth/authorize\" as const;\nexport const PERSONAL_GITHUB_TOKEN_URL = \"https://github.com/login/oauth/access_token\" as const;\nexport const PERSONAL_GITHUB_USER_URL = \"https://api.github.com/user\" as const;\nexport const PERSONAL_GITHUB_API_ORIGIN = \"https://api.github.com\" as const;\nexport const PERSONAL_GITHUB_REPOSITORY_CATALOG_MAX = 100 as const;\n\nexport const PersonalGitHubRepositoryId = z.string().regex(/^[1-9]\\d*$/u);\nexport type PersonalGitHubRepositoryId = z.infer<typeof PersonalGitHubRepositoryId>;\n\nexport const PersonalGitHubRepositoryAccess = z.enum([\"read\", \"write\"]);\nexport type PersonalGitHubRepositoryAccess = z.infer<typeof PersonalGitHubRepositoryAccess>;\n\nexport const PersonalGitHubRepositoryPermissions = z\n .object({\n pull: z.boolean(),\n push: z.boolean(),\n admin: z.boolean(),\n maintain: z.boolean(),\n triage: z.boolean(),\n })\n .strict();\nexport type PersonalGitHubRepositoryPermissions = z.infer<\n typeof PersonalGitHubRepositoryPermissions\n>;\n\nexport const PersonalGitHubRepositoryVisibility = z.enum([\"public\", \"private\", \"internal\"]);\nexport type PersonalGitHubRepositoryVisibility = z.infer<typeof PersonalGitHubRepositoryVisibility>;\n\nconst PersonalGitHubRepositoryFullName = z\n .string()\n .min(3)\n .max(140)\n .regex(/^[A-Za-z0-9](?:[A-Za-z0-9-]{0,38})\\/[A-Za-z0-9_.-]{1,100}$/u);\n\nexport function canonicalPersonalGitHubRepositoryUrl(fullName: string): string {\n return `https://github.com/${fullName}`;\n}\n\n/** A bounded, credential-free projection verified directly against GitHub. */\nexport const PersonalGitHubRepository = z\n .object({\n repositoryId: PersonalGitHubRepositoryId,\n fullName: PersonalGitHubRepositoryFullName,\n canonicalUrl: z.string().url().max(512),\n defaultBranch: z.string().min(1).max(255),\n visibility: PersonalGitHubRepositoryVisibility,\n private: z.boolean(),\n archived: z.boolean(),\n disabled: z.boolean(),\n permissions: PersonalGitHubRepositoryPermissions,\n })\n .strict()\n .superRefine((repository, context) => {\n if (repository.canonicalUrl !== canonicalPersonalGitHubRepositoryUrl(repository.fullName)) {\n context.addIssue({\n code: \"custom\",\n path: [\"canonicalUrl\"],\n message: \"canonicalUrl must be derived from fullName\",\n });\n }\n if (repository.private !== (repository.visibility === \"private\")) {\n context.addIssue({\n code: \"custom\",\n path: [\"private\"],\n message: \"private must agree with visibility\",\n });\n }\n });\nexport type PersonalGitHubRepository = z.infer<typeof PersonalGitHubRepository>;\n\nexport const PersonalGitHubSelectedRepository = PersonalGitHubRepository.safeExtend({\n selectedAccess: PersonalGitHubRepositoryAccess,\n selectionGeneration: z.number().int().positive(),\n selectedAt: z.string().datetime({ offset: true }),\n lastVerifiedAt: z.string().datetime({ offset: true }),\n}).strict();\nexport type PersonalGitHubSelectedRepository = z.infer<typeof PersonalGitHubSelectedRepository>;\n\nexport const PersonalGitHubRepositorySelectionState = z\n .object({\n connectionAuthorityGeneration: z.number().int().positive(),\n credentialBindingId: z.string().uuid(),\n providerPrincipalId: PersonalGitHubRepositoryId,\n selectionGeneration: z.number().int().nonnegative(),\n repositories: z\n .array(PersonalGitHubSelectedRepository)\n .max(PERSONAL_GITHUB_REPOSITORY_CATALOG_MAX),\n })\n .strict();\nexport type PersonalGitHubRepositorySelectionState = z.infer<\n typeof PersonalGitHubRepositorySelectionState\n>;\n\nexport const ListPersonalGitHubRepositoriesQuery = z\n .object({\n cursor: z.coerce.number().int().positive().max(10_000).default(1),\n limit: z.coerce.number().int().min(1).max(PERSONAL_GITHUB_REPOSITORY_CATALOG_MAX).default(50),\n })\n .strict();\nexport type ListPersonalGitHubRepositoriesQuery = z.infer<\n typeof ListPersonalGitHubRepositoriesQuery\n>;\n\nexport const PersonalGitHubRepositoryCatalogItem = PersonalGitHubRepository.safeExtend({\n selectedAccess: PersonalGitHubRepositoryAccess.nullable(),\n}).strict();\nexport type PersonalGitHubRepositoryCatalogItem = z.infer<\n typeof PersonalGitHubRepositoryCatalogItem\n>;\n\nexport const ListPersonalGitHubRepositoriesResponse = z\n .object({\n repositories: z\n .array(PersonalGitHubRepositoryCatalogItem)\n .max(PERSONAL_GITHUB_REPOSITORY_CATALOG_MAX),\n nextCursor: z.number().int().positive().nullable(),\n selection: PersonalGitHubRepositorySelectionState,\n })\n .strict();\nexport type ListPersonalGitHubRepositoriesResponse = z.infer<\n typeof ListPersonalGitHubRepositoriesResponse\n>;\n\nexport const PersonalGitHubRepositorySelectionInput = z\n .object({\n repositoryId: PersonalGitHubRepositoryId,\n fullName: PersonalGitHubRepositoryFullName,\n access: PersonalGitHubRepositoryAccess,\n })\n .strict();\nexport type PersonalGitHubRepositorySelectionInput = z.infer<\n typeof PersonalGitHubRepositorySelectionInput\n>;\n\nexport const ReplacePersonalGitHubRepositorySelectionsRequest = z\n .object({\n expectedConnectionAuthorityGeneration: z.number().int().positive(),\n expectedSelectionGeneration: z.number().int().nonnegative(),\n idempotencyKey: z.string().trim().min(1).max(200),\n repositories: z\n .array(PersonalGitHubRepositorySelectionInput)\n .max(PERSONAL_GITHUB_REPOSITORY_CATALOG_MAX),\n })\n .strict()\n .superRefine((request, context) => {\n const repositoryIds = new Set<string>();\n const fullNames = new Set<string>();\n request.repositories.forEach((repository, index) => {\n const normalizedFullName = repository.fullName.toLowerCase();\n if (repositoryIds.has(repository.repositoryId)) {\n context.addIssue({\n code: \"custom\",\n path: [\"repositories\", index, \"repositoryId\"],\n message: \"repositoryId must be unique\",\n });\n }\n if (fullNames.has(normalizedFullName)) {\n context.addIssue({\n code: \"custom\",\n path: [\"repositories\", index, \"fullName\"],\n message: \"fullName must be unique\",\n });\n }\n repositoryIds.add(repository.repositoryId);\n fullNames.add(normalizedFullName);\n });\n });\nexport type ReplacePersonalGitHubRepositorySelectionsRequest = z.infer<\n typeof ReplacePersonalGitHubRepositorySelectionsRequest\n>;\n\nexport const VerifyPersonalGitHubRepositorySelectionsRequest = z\n .object({\n expectedConnectionAuthorityGeneration: z.number().int().positive(),\n expectedSelectionGeneration: z.number().int().nonnegative(),\n idempotencyKey: z.string().trim().min(1).max(200),\n })\n .strict();\nexport type VerifyPersonalGitHubRepositorySelectionsRequest = z.infer<\n typeof VerifyPersonalGitHubRepositorySelectionsRequest\n>;\n\n/**\n * Owner-visible, credential-free metadata for one dedicated personal GitHub\n * OAuth connection. Repository selections are a separate authority and never\n * live in this credential record.\n */\nexport const PersonalGitHubConnectionMetadata = z\n .object({\n credentialRole: z.literal(PERSONAL_GITHUB_CREDENTIAL_ROLE),\n providerFamily: z.literal(PERSONAL_GITHUB_PROVIDER_FAMILY),\n providerPrincipalId: z.string().regex(/^\\d+$/u),\n githubUserId: z.string().regex(/^\\d+$/u),\n githubLogin: z.string().min(1).max(100),\n oauthEnvironment: z.string().min(1).max(128),\n oauthClientMarker: z.string().regex(/^[a-f0-9]{32}$/u),\n credentialBindingId: z.string().uuid(),\n connectedAt: z.string().datetime({ offset: true }),\n lastVerifiedAt: z.string().datetime({ offset: true }),\n disconnectedAt: z.string().datetime({ offset: true }).nullable().optional(),\n refreshTokenExpiresAt: z.string().datetime({ offset: true }).nullable().optional(),\n })\n .passthrough();\nexport type PersonalGitHubConnectionMetadata = z.infer<typeof PersonalGitHubConnectionMetadata>;\n\nexport const PersonalGitHubOAuthStartRequest = z\n .object({\n /** Existing exact connection generation to re-authorize in place. */\n connectionId: z.string().uuid().optional(),\n /** Same-workspace UI path restored after the callback. */\n returnPath: z.string().min(1).max(2048).optional(),\n })\n .strict();\nexport type PersonalGitHubOAuthStartRequest = z.infer<typeof PersonalGitHubOAuthStartRequest>;\n\nexport const PersonalGitHubOAuthStartResponse = z\n .object({\n authorizationUrl: z.string().url(),\n expiresAt: z.string().datetime({ offset: true }),\n })\n .strict();\nexport type PersonalGitHubOAuthStartResponse = z.infer<typeof PersonalGitHubOAuthStartResponse>;\n\nexport const PersonalGitHubConnectionStatusResponse = z\n .object({\n enabled: z.boolean(),\n connection: ConnectionMetadata.nullable(),\n reviewUrl: z.string().url().nullable(),\n })\n .strict();\nexport type PersonalGitHubConnectionStatusResponse = z.infer<\n typeof PersonalGitHubConnectionStatusResponse\n>;\n\nexport const PersonalGitHubDisconnectRequest = z\n .object({\n expectedVersion: z.number().int().positive(),\n idempotencyKey: z.string().trim().min(1).max(200),\n })\n .strict();\nexport type PersonalGitHubDisconnectRequest = z.infer<typeof PersonalGitHubDisconnectRequest>;\n\nexport function isPersonalGitHubConnection(\n connection: Pick<z.infer<typeof ConnectionMetadata>, \"providerDomain\" | \"kind\" | \"metadata\">,\n): boolean {\n return (\n connection.providerDomain.toLowerCase() === PERSONAL_GITHUB_PROVIDER_DOMAIN &&\n connection.kind === \"oauth2\" &&\n PersonalGitHubConnectionMetadata.safeParse(connection.metadata).success\n );\n}\n\nexport function hasReservedPersonalGitHubMetadata(\n metadata: Record<string, unknown> | undefined,\n): boolean {\n return metadata?.credentialRole === PERSONAL_GITHUB_CREDENTIAL_ROLE;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,SAAS;AAIX,IAAM,kCAAkC;AACxC,IAAM,kCAAkC;AACxC,IAAM,kCAAkC;AACxC,IAAM,wCAAwC;AAC9C,IAAM,mCAAmC,CAAC,MAAM;AAChD,IAAM,oCACX;AACK,IAAM,4BAA4B;AAClC,IAAM,2BAA2B;AACjC,IAAM,6BAA6B;AACnC,IAAM,yCAAyC;AAE/C,IAAM,6BAA6B,EAAE,OAAO,EAAE,MAAM,aAAa;AAGjE,IAAM,iCAAiC,EAAE,KAAK,CAAC,QAAQ,OAAO,CAAC;AAG/D,IAAM,sCAAsC,EAChD,OAAO;AAAA,EACN,MAAM,EAAE,QAAQ;AAAA,EAChB,MAAM,EAAE,QAAQ;AAAA,EAChB,OAAO,EAAE,QAAQ;AAAA,EACjB,UAAU,EAAE,QAAQ;AAAA,EACpB,QAAQ,EAAE,QAAQ;AACpB,CAAC,EACA,OAAO;AAKH,IAAM,qCAAqC,EAAE,KAAK,CAAC,UAAU,WAAW,UAAU,CAAC;AAG1F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B;AACtC;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeni/contracts",
3
- "version": "2.15.2",
3
+ "version": "3.0.0-canary.0",
4
4
  "description": "Shared zod schemas and wire-contract types for the OpenGeni API.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -18,6 +18,18 @@
18
18
  "module": "./dist/index.js",
19
19
  "types": "./dist/index.d.ts",
20
20
  "exports": {
21
+ "./host-mcp-bindings": {
22
+ "types": "./dist/host-mcp-bindings.d.ts",
23
+ "import": "./dist/host-mcp-bindings.js"
24
+ },
25
+ "./external-identities": {
26
+ "types": "./dist/external-identities.d.ts",
27
+ "import": "./dist/external-identities.js"
28
+ },
29
+ "./connect": {
30
+ "types": "./dist/connect.d.ts",
31
+ "import": "./dist/connect.js"
32
+ },
21
33
  "./site-session-http": {
22
34
  "types": "./dist/site-session-http.d.ts",
23
35
  "import": "./dist/site-session-http.js"
package/src/connect.ts ADDED
@@ -0,0 +1,202 @@
1
+ import { z } from "zod";
2
+ import { IntegrationInstanceKey, IntegrationSource } from "./index";
3
+
4
+ const opaqueId = z.string().min(1).max(512);
5
+ export const ConnectOwnership = z.enum(["personal", "workspace"]);
6
+ export type ConnectOwnership = z.infer<typeof ConnectOwnership>;
7
+ export const ConnectProvider = z
8
+ .object({
9
+ id: opaqueId,
10
+ label: z.string().min(1).max(256),
11
+ family: opaqueId,
12
+ readiness: z.enum(["available", "needs_configuration", "operator_only", "unsupported"]),
13
+ reason: z.string().max(1024).optional(),
14
+ ownership: z.array(ConnectOwnership).max(2),
15
+ setup: z
16
+ .array(
17
+ z.enum(["none", "oauth", "credentials", "device", "installation", "openapi", "graphql"]),
18
+ )
19
+ .max(7),
20
+ })
21
+ .strict();
22
+ export type ConnectProvider = z.infer<typeof ConnectProvider>;
23
+ export const ConnectAccount = z
24
+ .object({
25
+ id: opaqueId,
26
+ providerId: opaqueId,
27
+ version: z.number().int().positive().optional(),
28
+ label: z.string().max(256),
29
+ ownership: ConnectOwnership,
30
+ status: z.enum(["connected", "auth_needed", "disabled"]),
31
+ })
32
+ .strict();
33
+ export type ConnectAccount = z.infer<typeof ConnectAccount>;
34
+ export const ConnectResource = z
35
+ .object({ id: opaqueId, label: z.string().max(512), kind: opaqueId })
36
+ .strict();
37
+ export type ConnectResource = z.infer<typeof ConnectResource>;
38
+ export const ConnectNextAction = z.discriminatedUnion("type", [
39
+ z.object({ type: z.literal("authorize"), url: z.string().url().max(16_384) }).strict(),
40
+ z
41
+ .object({
42
+ type: z.literal("credentials"),
43
+ fields: z
44
+ .array(
45
+ z
46
+ .object({
47
+ name: opaqueId,
48
+ label: z.string().max(256),
49
+ required: z.boolean(),
50
+ secret: z.boolean(),
51
+ options: z
52
+ .array(z.object({ value: opaqueId, label: z.string().max(512) }).strict())
53
+ .max(1000)
54
+ .optional(),
55
+ })
56
+ .strict(),
57
+ )
58
+ .max(32),
59
+ })
60
+ .strict(),
61
+ z
62
+ .object({
63
+ type: z.literal("wait"),
64
+ pollAfterMs: z.number().int().min(250).max(60_000),
65
+ userCode: z.string().max(128).optional(),
66
+ verificationUrl: z.string().url().max(2048).optional(),
67
+ })
68
+ .strict(),
69
+ z
70
+ .object({ type: z.literal("select_account"), accounts: z.array(ConnectAccount).max(100) })
71
+ .strict(),
72
+ z
73
+ .object({
74
+ type: z.literal("select_resources"),
75
+ resources: z.array(ConnectResource).max(100),
76
+ cursor: z.string().max(2048).optional(),
77
+ })
78
+ .strict(),
79
+ z
80
+ .object({
81
+ type: z.literal("preview"),
82
+ previewId: opaqueId,
83
+ contentHash: opaqueId,
84
+ operations: z.array(ConnectResource).max(2000),
85
+ })
86
+ .strict(),
87
+ z.object({ type: z.literal("none") }).strict(),
88
+ ]);
89
+ export type ConnectNextAction = z.infer<typeof ConnectNextAction>;
90
+ export const ConnectInstallationTarget = z
91
+ .object({
92
+ instanceKey: IntegrationInstanceKey,
93
+ displayName: z.string().min(1).max(200),
94
+ expectedInstanceVersion: z.number().int().positive().optional(),
95
+ })
96
+ .strict();
97
+ export type ConnectInstallationTarget = z.infer<typeof ConnectInstallationTarget>;
98
+ export const ConnectAttemptState = z.enum([
99
+ "ready",
100
+ "requires_user_action",
101
+ "credential_input",
102
+ "provider_wait",
103
+ "account_selection",
104
+ "resource_selection",
105
+ "preview",
106
+ "installing",
107
+ "connected_but_incomplete",
108
+ "complete",
109
+ "cancelled",
110
+ "expired",
111
+ "failed",
112
+ "uncertain",
113
+ ]);
114
+ export const ConnectAttempt = z
115
+ .object({
116
+ id: opaqueId,
117
+ workspaceId: opaqueId,
118
+ providerId: opaqueId,
119
+ ownership: ConnectOwnership,
120
+ revision: z.number().int().positive(),
121
+ state: ConnectAttemptState,
122
+ credentialsCommitted: z.boolean(),
123
+ integrationInstalled: z.boolean(),
124
+ completionRequirement: z.enum(["connection", "integration", "provider_setup"]),
125
+ nextAction: ConnectNextAction,
126
+ expiresAt: z.string().datetime({ offset: true }),
127
+ account: ConnectAccount.optional(),
128
+ installationTarget: ConnectInstallationTarget.optional(),
129
+ source: IntegrationSource.optional(),
130
+ error: z
131
+ .object({ code: opaqueId, message: z.string().max(2048), retryable: z.boolean() })
132
+ .strict()
133
+ .optional(),
134
+ })
135
+ .strict()
136
+ .superRefine((value, context) => {
137
+ if (
138
+ value.state === "complete" &&
139
+ value.completionRequirement === "integration" &&
140
+ !value.integrationInstalled
141
+ ) {
142
+ context.addIssue({
143
+ code: "custom",
144
+ message: "Complete setup requires an installed integration",
145
+ });
146
+ }
147
+ if (
148
+ value.state === "complete" &&
149
+ value.completionRequirement === "connection" &&
150
+ !value.credentialsCommitted
151
+ ) {
152
+ context.addIssue({
153
+ code: "custom",
154
+ message: "Connection setup requires committed credentials",
155
+ });
156
+ }
157
+ if (
158
+ ["complete", "cancelled", "expired"].includes(value.state) &&
159
+ value.nextAction.type !== "none"
160
+ ) {
161
+ context.addIssue({ code: "custom", message: "A terminal setup has no next action" });
162
+ }
163
+ });
164
+ export type ConnectAttempt = z.infer<typeof ConnectAttempt>;
165
+ export const ConnectAdvance = z.discriminatedUnion("type", [
166
+ z
167
+ .object({
168
+ type: z.literal("credentials"),
169
+ values: z.record(z.string().max(256), z.string().max(16_384)),
170
+ })
171
+ .strict(),
172
+ z.object({ type: z.literal("account"), accountId: opaqueId }).strict(),
173
+ z.object({ type: z.literal("resources"), resourceIds: z.array(opaqueId).max(1000) }).strict(),
174
+ z
175
+ .object({
176
+ type: z.literal("install"),
177
+ previewId: opaqueId,
178
+ contentHash: opaqueId,
179
+ operationIds: z.array(opaqueId).max(2000),
180
+ })
181
+ .strict(),
182
+ z.object({ type: z.literal("retry") }).strict(),
183
+ ]);
184
+ export type ConnectAdvance = z.infer<typeof ConnectAdvance>;
185
+ export const ConnectOperationRequest = z
186
+ .object({
187
+ expectedRevision: z.number().int().positive().safe(),
188
+ idempotencyKey: opaqueId,
189
+ })
190
+ .strict();
191
+ export const AdvanceConnectRequest = ConnectOperationRequest.extend({ action: ConnectAdvance });
192
+ export const BeginConnectRequest = z
193
+ .object({
194
+ providerId: opaqueId,
195
+ ownership: ConnectOwnership,
196
+ // URL parsing validates separately; never transform this original string.
197
+ returnUrl: z.string().min(1).max(4096),
198
+ idempotencyKey: opaqueId,
199
+ reconnectAccountId: opaqueId.optional(),
200
+ installationTarget: ConnectInstallationTarget.optional(),
201
+ })
202
+ .strict();