@omnicross/core 0.1.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 (114) hide show
  1. package/LICENSE +21 -0
  2. package/NOTICE +57 -0
  3. package/README.md +15 -0
  4. package/dist/ApiKeyPoolService-BmMkau07.d.cts +170 -0
  5. package/dist/ApiKeyPoolService-BmMkau07.d.ts +170 -0
  6. package/dist/ProviderProxy-f_8ziIhW.d.cts +120 -0
  7. package/dist/ProviderProxy-vjt8sQQk.d.ts +120 -0
  8. package/dist/SubscriptionAuthSource-Cr4fVEYY.d.cts +264 -0
  9. package/dist/SubscriptionAuthSource-D89zmiSS.d.ts +264 -0
  10. package/dist/auth/GeminiCodeAssistProjectResolver.cjs +218 -0
  11. package/dist/auth/GeminiCodeAssistProjectResolver.d.cts +68 -0
  12. package/dist/auth/GeminiCodeAssistProjectResolver.d.ts +68 -0
  13. package/dist/auth/GeminiCodeAssistProjectResolver.js +189 -0
  14. package/dist/completion/ApiKeyPoolService.cjs +331 -0
  15. package/dist/completion/ApiKeyPoolService.d.cts +2 -0
  16. package/dist/completion/ApiKeyPoolService.d.ts +2 -0
  17. package/dist/completion/ApiKeyPoolService.js +306 -0
  18. package/dist/completion.cjs +4027 -0
  19. package/dist/completion.d.cts +17 -0
  20. package/dist/completion.d.ts +17 -0
  21. package/dist/completion.js +3983 -0
  22. package/dist/index-BTSmc9Sm.d.ts +645 -0
  23. package/dist/index-DXazdTzZ.d.cts +645 -0
  24. package/dist/index.cjs +10428 -0
  25. package/dist/index.d.cts +128 -0
  26. package/dist/index.d.ts +128 -0
  27. package/dist/index.js +10339 -0
  28. package/dist/outbound-api/subscriptionRegistryPort.cjs +38 -0
  29. package/dist/outbound-api/subscriptionRegistryPort.d.cts +73 -0
  30. package/dist/outbound-api/subscriptionRegistryPort.d.ts +73 -0
  31. package/dist/outbound-api/subscriptionRegistryPort.js +12 -0
  32. package/dist/outbound-api.cjs +5264 -0
  33. package/dist/outbound-api.d.cts +320 -0
  34. package/dist/outbound-api.d.ts +320 -0
  35. package/dist/outbound-api.js +5218 -0
  36. package/dist/pipeline/SubscriptionAuthSource.cjs +131 -0
  37. package/dist/pipeline/SubscriptionAuthSource.d.cts +3 -0
  38. package/dist/pipeline/SubscriptionAuthSource.d.ts +3 -0
  39. package/dist/pipeline/SubscriptionAuthSource.js +103 -0
  40. package/dist/pipeline/SubscriptionAuthStrategy.cjs +18 -0
  41. package/dist/pipeline/SubscriptionAuthStrategy.d.cts +61 -0
  42. package/dist/pipeline/SubscriptionAuthStrategy.d.ts +61 -0
  43. package/dist/pipeline/SubscriptionAuthStrategy.js +0 -0
  44. package/dist/ports/gemini-code-assist-resolver.cjs +38 -0
  45. package/dist/ports/gemini-code-assist-resolver.d.cts +26 -0
  46. package/dist/ports/gemini-code-assist-resolver.d.ts +26 -0
  47. package/dist/ports/gemini-code-assist-resolver.js +12 -0
  48. package/dist/ports.cjs +18 -0
  49. package/dist/ports.d.cts +15 -0
  50. package/dist/ports.d.ts +15 -0
  51. package/dist/ports.js +0 -0
  52. package/dist/provider-proxy/ingress/providerProxyShared.cjs +2958 -0
  53. package/dist/provider-proxy/ingress/providerProxyShared.d.cts +77 -0
  54. package/dist/provider-proxy/ingress/providerProxyShared.d.ts +77 -0
  55. package/dist/provider-proxy/ingress/providerProxyShared.js +2925 -0
  56. package/dist/provider-proxy/matchText.cjs +73 -0
  57. package/dist/provider-proxy/matchText.d.cts +47 -0
  58. package/dist/provider-proxy/matchText.d.ts +47 -0
  59. package/dist/provider-proxy/matchText.js +45 -0
  60. package/dist/provider-proxy/types.cjs +18 -0
  61. package/dist/provider-proxy/types.d.cts +12 -0
  62. package/dist/provider-proxy/types.d.ts +12 -0
  63. package/dist/provider-proxy/types.js +0 -0
  64. package/dist/provider-proxy.cjs +4667 -0
  65. package/dist/provider-proxy.d.cts +69 -0
  66. package/dist/provider-proxy.d.ts +69 -0
  67. package/dist/provider-proxy.js +4636 -0
  68. package/dist/serializeError.cjs +82 -0
  69. package/dist/serializeError.d.cts +24 -0
  70. package/dist/serializeError.d.ts +24 -0
  71. package/dist/serializeError.js +57 -0
  72. package/dist/sse-parser.cjs +456 -0
  73. package/dist/sse-parser.d.cts +143 -0
  74. package/dist/sse-parser.d.ts +143 -0
  75. package/dist/sse-parser.js +430 -0
  76. package/dist/transformer/TransformerChainExecutor.cjs +321 -0
  77. package/dist/transformer/TransformerChainExecutor.d.cts +104 -0
  78. package/dist/transformer/TransformerChainExecutor.d.ts +104 -0
  79. package/dist/transformer/TransformerChainExecutor.js +294 -0
  80. package/dist/transformer/TransformerService.cjs +290 -0
  81. package/dist/transformer/TransformerService.d.cts +138 -0
  82. package/dist/transformer/TransformerService.d.ts +138 -0
  83. package/dist/transformer/TransformerService.js +265 -0
  84. package/dist/transformer/transformers/GeminiCodeAssistTransformer.cjs +1115 -0
  85. package/dist/transformer/transformers/GeminiCodeAssistTransformer.d.cts +102 -0
  86. package/dist/transformer/transformers/GeminiCodeAssistTransformer.d.ts +102 -0
  87. package/dist/transformer/transformers/GeminiCodeAssistTransformer.js +1085 -0
  88. package/dist/transformer/transformers/GeminiTransformer.cjs +1013 -0
  89. package/dist/transformer/transformers/GeminiTransformer.d.cts +70 -0
  90. package/dist/transformer/transformers/GeminiTransformer.d.ts +70 -0
  91. package/dist/transformer/transformers/GeminiTransformer.js +986 -0
  92. package/dist/transformer/transformers/OpenAIResponseTransformer.cjs +538 -0
  93. package/dist/transformer/transformers/OpenAIResponseTransformer.d.cts +53 -0
  94. package/dist/transformer/transformers/OpenAIResponseTransformer.d.ts +53 -0
  95. package/dist/transformer/transformers/OpenAIResponseTransformer.js +513 -0
  96. package/dist/transformer/transformers/OpenCodeGoTransformer.cjs +73 -0
  97. package/dist/transformer/transformers/OpenCodeGoTransformer.d.cts +51 -0
  98. package/dist/transformer/transformers/OpenCodeGoTransformer.d.ts +51 -0
  99. package/dist/transformer/transformers/OpenCodeGoTransformer.js +48 -0
  100. package/dist/transformer/types.cjs +18 -0
  101. package/dist/transformer/types.d.cts +405 -0
  102. package/dist/transformer/types.d.ts +405 -0
  103. package/dist/transformer/types.js +0 -0
  104. package/dist/transformer.cjs +3736 -0
  105. package/dist/transformer.d.cts +33 -0
  106. package/dist/transformer.d.ts +33 -0
  107. package/dist/transformer.js +3712 -0
  108. package/dist/types-CGGrKqC_.d.cts +142 -0
  109. package/dist/types-CbCN2NQP.d.ts +142 -0
  110. package/dist/types-DCzHkhJt.d.ts +467 -0
  111. package/dist/types-DZIQbgp0.d.cts +467 -0
  112. package/dist/usage-event-sink-BX7FE1NL.d.cts +59 -0
  113. package/dist/usage-event-sink-BX7FE1NL.d.ts +59 -0
  114. package/package.json +62 -0
@@ -0,0 +1,131 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/pipeline/SubscriptionAuthSource.ts
21
+ var SubscriptionAuthSource_exports = {};
22
+ __export(SubscriptionAuthSource_exports, {
23
+ SubscriptionAuthSource: () => SubscriptionAuthSource,
24
+ stripAuthHeaders: () => stripAuthHeaders
25
+ });
26
+ module.exports = __toCommonJS(SubscriptionAuthSource_exports);
27
+
28
+ // src/serializeError.ts
29
+ function serializeError(err) {
30
+ if (err == null) return "Unknown error (null)";
31
+ if (err instanceof Error) {
32
+ let msg = err.message || err.name || "Error";
33
+ if (err.cause) {
34
+ msg += ` [cause: ${serializeError(err.cause)}]`;
35
+ }
36
+ const anyErr = err;
37
+ if (anyErr.status != null) msg += ` (status: ${anyErr.status})`;
38
+ else if (anyErr.code != null) msg += ` (code: ${anyErr.code})`;
39
+ return msg;
40
+ }
41
+ if (typeof err === "string") return err || "Empty error string";
42
+ if (typeof err !== "object") return String(err);
43
+ const obj = err;
44
+ if (typeof obj.message === "string" && obj.message) {
45
+ let msg = obj.message;
46
+ if (obj.status != null) msg += ` (status: ${obj.status})`;
47
+ else if (obj.code != null) msg += ` (code: ${obj.code})`;
48
+ if (typeof obj.type === "string") msg += ` [type: ${obj.type}]`;
49
+ return msg;
50
+ }
51
+ if (typeof obj.error === "string" && obj.error) {
52
+ return obj.error;
53
+ }
54
+ if (obj.error && typeof obj.error === "object") {
55
+ const inner = obj.error;
56
+ if (typeof inner.message === "string" && inner.message) {
57
+ let msg = inner.message;
58
+ if (typeof inner.type === "string") msg += ` [type: ${inner.type}]`;
59
+ return msg;
60
+ }
61
+ }
62
+ try {
63
+ const json = JSON.stringify(err, getCircularReplacer(), 2);
64
+ if (json && json.length > 1e3) {
65
+ return json.slice(0, 1e3) + "... (truncated)";
66
+ }
67
+ return json || "Unserializable error";
68
+ } catch {
69
+ return `Unserializable error: ${Object.prototype.toString.call(err)}`;
70
+ }
71
+ }
72
+ function getCircularReplacer() {
73
+ const seen = /* @__PURE__ */ new WeakSet();
74
+ return (_key, value) => {
75
+ if (typeof value === "object" && value !== null) {
76
+ if (seen.has(value)) return "[Circular]";
77
+ seen.add(value);
78
+ }
79
+ return value;
80
+ };
81
+ }
82
+
83
+ // src/pipeline/SubscriptionAuthSource.ts
84
+ function stripAuthHeaders(headers) {
85
+ delete headers.authorization;
86
+ delete headers.Authorization;
87
+ delete headers["x-api-key"];
88
+ delete headers["X-Api-Key"];
89
+ delete headers["x-goog-api-key"];
90
+ delete headers["X-Goog-Api-Key"];
91
+ }
92
+ var SubscriptionAuthSource = class {
93
+ constructor(profile) {
94
+ this.profile = profile;
95
+ }
96
+ profile;
97
+ /**
98
+ * Strip any transformer-set auth headers, then delegate to the bound
99
+ * strategy. Mirrors `SubscriptionDispatcher`'s
100
+ * `stripAuthHeaders(...)` + `applyHeadersWithRetry(...)` sequence, including
101
+ * the best-effort swallow-and-warn around a throwing `applyHeaders`.
102
+ *
103
+ * The strategy's looser `AuthApplyHints` (optional `upstreamUrl` /
104
+ * `resolvedModel`) is fed from the pipeline's required `{ upstreamUrl,
105
+ * model }` at the boundary.
106
+ */
107
+ async applyHeaders(headers, hints) {
108
+ stripAuthHeaders(headers);
109
+ try {
110
+ await this.profile.authStrategy.applyHeaders(headers, {
111
+ upstreamUrl: hints.upstreamUrl,
112
+ resolvedModel: hints.model
113
+ });
114
+ } catch (err) {
115
+ console.warn("[SubscriptionAuthSource] authStrategy.applyHeaders threw:", serializeError(err));
116
+ }
117
+ }
118
+ /** Delegate the 401-refresh decision to the bound strategy. */
119
+ async onUnauthorized() {
120
+ return this.profile.authStrategy.onUnauthorized();
121
+ }
122
+ /** Resolve the upstream URL from the profile, when it provides one. */
123
+ resolveUpstreamUrl(model) {
124
+ return this.profile.resolveUpstreamUrl?.(model);
125
+ }
126
+ };
127
+ // Annotate the CommonJS export names for ESM import in node:
128
+ 0 && (module.exports = {
129
+ SubscriptionAuthSource,
130
+ stripAuthHeaders
131
+ });
@@ -0,0 +1,3 @@
1
+ import '@omnicross/contracts/subscription-types';
2
+ export { S as SubscriptionAuthProfile, a as SubscriptionAuthSource, b as SubscriptionRequestSummary, s as stripAuthHeaders } from '../SubscriptionAuthSource-Cr4fVEYY.cjs';
3
+ import './SubscriptionAuthStrategy.cjs';
@@ -0,0 +1,3 @@
1
+ import '@omnicross/contracts/subscription-types';
2
+ export { S as SubscriptionAuthProfile, a as SubscriptionAuthSource, b as SubscriptionRequestSummary, s as stripAuthHeaders } from '../SubscriptionAuthSource-D89zmiSS.js';
3
+ import './SubscriptionAuthStrategy.js';
@@ -0,0 +1,103 @@
1
+ // src/serializeError.ts
2
+ function serializeError(err) {
3
+ if (err == null) return "Unknown error (null)";
4
+ if (err instanceof Error) {
5
+ let msg = err.message || err.name || "Error";
6
+ if (err.cause) {
7
+ msg += ` [cause: ${serializeError(err.cause)}]`;
8
+ }
9
+ const anyErr = err;
10
+ if (anyErr.status != null) msg += ` (status: ${anyErr.status})`;
11
+ else if (anyErr.code != null) msg += ` (code: ${anyErr.code})`;
12
+ return msg;
13
+ }
14
+ if (typeof err === "string") return err || "Empty error string";
15
+ if (typeof err !== "object") return String(err);
16
+ const obj = err;
17
+ if (typeof obj.message === "string" && obj.message) {
18
+ let msg = obj.message;
19
+ if (obj.status != null) msg += ` (status: ${obj.status})`;
20
+ else if (obj.code != null) msg += ` (code: ${obj.code})`;
21
+ if (typeof obj.type === "string") msg += ` [type: ${obj.type}]`;
22
+ return msg;
23
+ }
24
+ if (typeof obj.error === "string" && obj.error) {
25
+ return obj.error;
26
+ }
27
+ if (obj.error && typeof obj.error === "object") {
28
+ const inner = obj.error;
29
+ if (typeof inner.message === "string" && inner.message) {
30
+ let msg = inner.message;
31
+ if (typeof inner.type === "string") msg += ` [type: ${inner.type}]`;
32
+ return msg;
33
+ }
34
+ }
35
+ try {
36
+ const json = JSON.stringify(err, getCircularReplacer(), 2);
37
+ if (json && json.length > 1e3) {
38
+ return json.slice(0, 1e3) + "... (truncated)";
39
+ }
40
+ return json || "Unserializable error";
41
+ } catch {
42
+ return `Unserializable error: ${Object.prototype.toString.call(err)}`;
43
+ }
44
+ }
45
+ function getCircularReplacer() {
46
+ const seen = /* @__PURE__ */ new WeakSet();
47
+ return (_key, value) => {
48
+ if (typeof value === "object" && value !== null) {
49
+ if (seen.has(value)) return "[Circular]";
50
+ seen.add(value);
51
+ }
52
+ return value;
53
+ };
54
+ }
55
+
56
+ // src/pipeline/SubscriptionAuthSource.ts
57
+ function stripAuthHeaders(headers) {
58
+ delete headers.authorization;
59
+ delete headers.Authorization;
60
+ delete headers["x-api-key"];
61
+ delete headers["X-Api-Key"];
62
+ delete headers["x-goog-api-key"];
63
+ delete headers["X-Goog-Api-Key"];
64
+ }
65
+ var SubscriptionAuthSource = class {
66
+ constructor(profile) {
67
+ this.profile = profile;
68
+ }
69
+ profile;
70
+ /**
71
+ * Strip any transformer-set auth headers, then delegate to the bound
72
+ * strategy. Mirrors `SubscriptionDispatcher`'s
73
+ * `stripAuthHeaders(...)` + `applyHeadersWithRetry(...)` sequence, including
74
+ * the best-effort swallow-and-warn around a throwing `applyHeaders`.
75
+ *
76
+ * The strategy's looser `AuthApplyHints` (optional `upstreamUrl` /
77
+ * `resolvedModel`) is fed from the pipeline's required `{ upstreamUrl,
78
+ * model }` at the boundary.
79
+ */
80
+ async applyHeaders(headers, hints) {
81
+ stripAuthHeaders(headers);
82
+ try {
83
+ await this.profile.authStrategy.applyHeaders(headers, {
84
+ upstreamUrl: hints.upstreamUrl,
85
+ resolvedModel: hints.model
86
+ });
87
+ } catch (err) {
88
+ console.warn("[SubscriptionAuthSource] authStrategy.applyHeaders threw:", serializeError(err));
89
+ }
90
+ }
91
+ /** Delegate the 401-refresh decision to the bound strategy. */
92
+ async onUnauthorized() {
93
+ return this.profile.authStrategy.onUnauthorized();
94
+ }
95
+ /** Resolve the upstream URL from the profile, when it provides one. */
96
+ resolveUpstreamUrl(model) {
97
+ return this.profile.resolveUpstreamUrl?.(model);
98
+ }
99
+ };
100
+ export {
101
+ SubscriptionAuthSource,
102
+ stripAuthHeaders
103
+ };
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+
16
+ // src/pipeline/SubscriptionAuthStrategy.ts
17
+ var SubscriptionAuthStrategy_exports = {};
18
+ module.exports = __toCommonJS(SubscriptionAuthStrategy_exports);
@@ -0,0 +1,61 @@
1
+ import { SubscriptionProviderId, SubscriptionStatusEntry } from '@omnicross/contracts/subscription-types';
2
+
3
+ /**
4
+ * SubscriptionAuthStrategy — the pluggable subscription-auth contract, defined
5
+ * in the serving core (`pipeline/`).
6
+ *
7
+ * Each subscription provider in the `SubscriptionProviderRegistry` (the
8
+ * subscriptions package) carries an `AuthStrategy` instance. The proxy calls
9
+ * `applyHeaders` before issuing the upstream request and `onUnauthorized`
10
+ * after a 401 to ask whether to retry.
11
+ *
12
+ * It is a PURE contract (no upstream semantics), defined down here so
13
+ * `pipeline/SubscriptionAuthSource.ts` consumes it WITHOUT importing upward
14
+ * (correct dependency direction). The subscriptions package's
15
+ * `auth/AuthStrategy.ts` RE-EXPORTS this type, and its three concrete
16
+ * strategies implement THIS interface — so they remain assignable and no
17
+ * downstream consumer's import path changes.
18
+ *
19
+ * NOTE: this `AuthApplyHints` (OPTIONAL fields) is the SUBSCRIPTION-side hint
20
+ * shape and is intentionally distinct from `pipeline/AuthSource.ts`'s
21
+ * `AuthApplyHints` (REQUIRED fields). They are not interchangeable; the
22
+ * `SubscriptionAuthSource` adapter maps between them at the boundary.
23
+ *
24
+ * @module pipeline/SubscriptionAuthStrategy
25
+ */
26
+
27
+ /** Hints the strategy may need to vary header formatting per request. */
28
+ interface AuthApplyHints {
29
+ /** Resolved upstream URL — used by some strategies (e.g. OpenCodeGo) to
30
+ * choose between Anthropic-shape and OpenAI-shape headers. */
31
+ upstreamUrl?: string;
32
+ /** Resolved model id — same purpose as `upstreamUrl`. */
33
+ resolvedModel?: string;
34
+ }
35
+ interface AuthStrategy {
36
+ /** Discriminator — also surfaced through `subscription:list` to renderers. */
37
+ readonly kind: 'pass-through' | 'oauth-bearer' | 'static-bearer';
38
+ /** Stable id of the bound subscription provider. */
39
+ readonly providerId: SubscriptionProviderId;
40
+ /**
41
+ * Inject any required authentication headers into the outbound request.
42
+ * Implementations MAY refresh expiring tokens here (transparent refresh).
43
+ *
44
+ * Pass-through implementations are a no-op; the proxy's pass-through
45
+ * code path preserves the SDK's own Authorization header instead.
46
+ */
47
+ applyHeaders(headers: Record<string, string>, hints?: AuthApplyHints): Promise<void>;
48
+ /**
49
+ * Called when the upstream returns 401. Return `true` to ask the proxy to
50
+ * retry the request once with freshly-applied headers; return `false` to
51
+ * surface the 401 immediately.
52
+ *
53
+ * Implementations SHOULD use a shared `RefreshMutex` to dedupe concurrent
54
+ * refreshes so N parallel 401s collapse into one upstream refresh call.
55
+ */
56
+ onUnauthorized(): Promise<boolean>;
57
+ /** Diagnostic surface for the `subscription:status` IPC. */
58
+ describeStatus(): Promise<SubscriptionStatusEntry>;
59
+ }
60
+
61
+ export type { AuthApplyHints, AuthStrategy };
@@ -0,0 +1,61 @@
1
+ import { SubscriptionProviderId, SubscriptionStatusEntry } from '@omnicross/contracts/subscription-types';
2
+
3
+ /**
4
+ * SubscriptionAuthStrategy — the pluggable subscription-auth contract, defined
5
+ * in the serving core (`pipeline/`).
6
+ *
7
+ * Each subscription provider in the `SubscriptionProviderRegistry` (the
8
+ * subscriptions package) carries an `AuthStrategy` instance. The proxy calls
9
+ * `applyHeaders` before issuing the upstream request and `onUnauthorized`
10
+ * after a 401 to ask whether to retry.
11
+ *
12
+ * It is a PURE contract (no upstream semantics), defined down here so
13
+ * `pipeline/SubscriptionAuthSource.ts` consumes it WITHOUT importing upward
14
+ * (correct dependency direction). The subscriptions package's
15
+ * `auth/AuthStrategy.ts` RE-EXPORTS this type, and its three concrete
16
+ * strategies implement THIS interface — so they remain assignable and no
17
+ * downstream consumer's import path changes.
18
+ *
19
+ * NOTE: this `AuthApplyHints` (OPTIONAL fields) is the SUBSCRIPTION-side hint
20
+ * shape and is intentionally distinct from `pipeline/AuthSource.ts`'s
21
+ * `AuthApplyHints` (REQUIRED fields). They are not interchangeable; the
22
+ * `SubscriptionAuthSource` adapter maps between them at the boundary.
23
+ *
24
+ * @module pipeline/SubscriptionAuthStrategy
25
+ */
26
+
27
+ /** Hints the strategy may need to vary header formatting per request. */
28
+ interface AuthApplyHints {
29
+ /** Resolved upstream URL — used by some strategies (e.g. OpenCodeGo) to
30
+ * choose between Anthropic-shape and OpenAI-shape headers. */
31
+ upstreamUrl?: string;
32
+ /** Resolved model id — same purpose as `upstreamUrl`. */
33
+ resolvedModel?: string;
34
+ }
35
+ interface AuthStrategy {
36
+ /** Discriminator — also surfaced through `subscription:list` to renderers. */
37
+ readonly kind: 'pass-through' | 'oauth-bearer' | 'static-bearer';
38
+ /** Stable id of the bound subscription provider. */
39
+ readonly providerId: SubscriptionProviderId;
40
+ /**
41
+ * Inject any required authentication headers into the outbound request.
42
+ * Implementations MAY refresh expiring tokens here (transparent refresh).
43
+ *
44
+ * Pass-through implementations are a no-op; the proxy's pass-through
45
+ * code path preserves the SDK's own Authorization header instead.
46
+ */
47
+ applyHeaders(headers: Record<string, string>, hints?: AuthApplyHints): Promise<void>;
48
+ /**
49
+ * Called when the upstream returns 401. Return `true` to ask the proxy to
50
+ * retry the request once with freshly-applied headers; return `false` to
51
+ * surface the 401 immediately.
52
+ *
53
+ * Implementations SHOULD use a shared `RefreshMutex` to dedupe concurrent
54
+ * refreshes so N parallel 401s collapse into one upstream refresh call.
55
+ */
56
+ onUnauthorized(): Promise<boolean>;
57
+ /** Diagnostic surface for the `subscription:status` IPC. */
58
+ describeStatus(): Promise<SubscriptionStatusEntry>;
59
+ }
60
+
61
+ export type { AuthApplyHints, AuthStrategy };
File without changes
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/ports/gemini-code-assist-resolver.ts
21
+ var gemini_code_assist_resolver_exports = {};
22
+ __export(gemini_code_assist_resolver_exports, {
23
+ getGeminiCodeAssistResolver: () => getGeminiCodeAssistResolver,
24
+ setGeminiCodeAssistResolver: () => setGeminiCodeAssistResolver
25
+ });
26
+ module.exports = __toCommonJS(gemini_code_assist_resolver_exports);
27
+ var resolver = null;
28
+ function setGeminiCodeAssistResolver(impl) {
29
+ resolver = impl;
30
+ }
31
+ function getGeminiCodeAssistResolver() {
32
+ return resolver;
33
+ }
34
+ // Annotate the CommonJS export names for ESM import in node:
35
+ 0 && (module.exports = {
36
+ getGeminiCodeAssistResolver,
37
+ setGeminiCodeAssistResolver
38
+ });
@@ -0,0 +1,26 @@
1
+ /**
2
+ * GeminiCodeAssistResolver port.
3
+ *
4
+ * The OpenAI Responses ingress (gemini subscription path) resolves the Gemini
5
+ * Code Assist project id for a gemini subscription account. The concrete
6
+ * resolver (`GeminiCodeAssistProjectResolver`) is HOST-CLEAN and lives in the
7
+ * serving core itself (`@omnicross/core/auth/GeminiCodeAssistProjectResolver`):
8
+ * it imports only the core Gemini transformer helpers, `fetch`, and
9
+ * `process.env` — it couples to NO host token/OAuth service.
10
+ *
11
+ * Even so, the ingress reads it through this narrow port + module-level
12
+ * injection slot rather than importing the impl directly, so each embedder wires
13
+ * the same shared resolver at bootstrap (e.g. via
14
+ * `setGeminiCodeAssistResolver(getGeminiCodeAssistProjectResolver())`). An
15
+ * unwired slot resolves `undefined` (the valid free-tier no-project case).
16
+ */
17
+ /** Narrow structural port for the Gemini Code Assist project resolver. */
18
+ interface GeminiCodeAssistResolverPort {
19
+ resolveProject(accessToken: string): Promise<string | undefined>;
20
+ }
21
+ /** Each embedder wires the concrete (core-resident) resolver at bootstrap. */
22
+ declare function setGeminiCodeAssistResolver(impl: GeminiCodeAssistResolverPort | null): void;
23
+ /** The ingress reads the injected resolver (null until an embedder wires it). */
24
+ declare function getGeminiCodeAssistResolver(): GeminiCodeAssistResolverPort | null;
25
+
26
+ export { type GeminiCodeAssistResolverPort, getGeminiCodeAssistResolver, setGeminiCodeAssistResolver };
@@ -0,0 +1,26 @@
1
+ /**
2
+ * GeminiCodeAssistResolver port.
3
+ *
4
+ * The OpenAI Responses ingress (gemini subscription path) resolves the Gemini
5
+ * Code Assist project id for a gemini subscription account. The concrete
6
+ * resolver (`GeminiCodeAssistProjectResolver`) is HOST-CLEAN and lives in the
7
+ * serving core itself (`@omnicross/core/auth/GeminiCodeAssistProjectResolver`):
8
+ * it imports only the core Gemini transformer helpers, `fetch`, and
9
+ * `process.env` — it couples to NO host token/OAuth service.
10
+ *
11
+ * Even so, the ingress reads it through this narrow port + module-level
12
+ * injection slot rather than importing the impl directly, so each embedder wires
13
+ * the same shared resolver at bootstrap (e.g. via
14
+ * `setGeminiCodeAssistResolver(getGeminiCodeAssistProjectResolver())`). An
15
+ * unwired slot resolves `undefined` (the valid free-tier no-project case).
16
+ */
17
+ /** Narrow structural port for the Gemini Code Assist project resolver. */
18
+ interface GeminiCodeAssistResolverPort {
19
+ resolveProject(accessToken: string): Promise<string | undefined>;
20
+ }
21
+ /** Each embedder wires the concrete (core-resident) resolver at bootstrap. */
22
+ declare function setGeminiCodeAssistResolver(impl: GeminiCodeAssistResolverPort | null): void;
23
+ /** The ingress reads the injected resolver (null until an embedder wires it). */
24
+ declare function getGeminiCodeAssistResolver(): GeminiCodeAssistResolverPort | null;
25
+
26
+ export { type GeminiCodeAssistResolverPort, getGeminiCodeAssistResolver, setGeminiCodeAssistResolver };
@@ -0,0 +1,12 @@
1
+ // src/ports/gemini-code-assist-resolver.ts
2
+ var resolver = null;
3
+ function setGeminiCodeAssistResolver(impl) {
4
+ resolver = impl;
5
+ }
6
+ function getGeminiCodeAssistResolver() {
7
+ return resolver;
8
+ }
9
+ export {
10
+ getGeminiCodeAssistResolver,
11
+ setGeminiCodeAssistResolver
12
+ };
package/dist/ports.cjs ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+
16
+ // src/ports/index.ts
17
+ var ports_exports = {};
18
+ module.exports = __toCommonJS(ports_exports);
@@ -0,0 +1,15 @@
1
+ export { C as CorePaths, a as CoreUsageEvent, b as CoreUsageTokenCounts, U as UsageEventSink } from './usage-event-sink-BX7FE1NL.cjs';
2
+ export { L as Logger } from './ApiKeyPoolService-BmMkau07.cjs';
3
+ export { P as ProviderConfigSource, U as UsageSink, W as WebSearchBackend } from './types-DZIQbgp0.cjs';
4
+ export { O as OutboundCredentialStore } from './types-CGGrKqC_.cjs';
5
+ import '@omnicross/contracts/llm-config';
6
+ import 'node:http';
7
+ import '@omnicross/contracts/completion-types';
8
+ import '@omnicross/contracts/subscription-types';
9
+ import '@omnicross/contracts/usage-types';
10
+ import './SubscriptionAuthSource-Cr4fVEYY.cjs';
11
+ import './pipeline/SubscriptionAuthStrategy.cjs';
12
+ import './transformer/types.cjs';
13
+ import './transformer/TransformerService.cjs';
14
+ import '@omnicross/contracts/websearch-types';
15
+ import './ProviderProxy-f_8ziIhW.cjs';
@@ -0,0 +1,15 @@
1
+ export { C as CorePaths, a as CoreUsageEvent, b as CoreUsageTokenCounts, U as UsageEventSink } from './usage-event-sink-BX7FE1NL.js';
2
+ export { L as Logger } from './ApiKeyPoolService-BmMkau07.js';
3
+ export { P as ProviderConfigSource, U as UsageSink, W as WebSearchBackend } from './types-DCzHkhJt.js';
4
+ export { O as OutboundCredentialStore } from './types-CbCN2NQP.js';
5
+ import '@omnicross/contracts/llm-config';
6
+ import 'node:http';
7
+ import '@omnicross/contracts/completion-types';
8
+ import '@omnicross/contracts/subscription-types';
9
+ import '@omnicross/contracts/usage-types';
10
+ import './SubscriptionAuthSource-D89zmiSS.js';
11
+ import './pipeline/SubscriptionAuthStrategy.js';
12
+ import './transformer/types.js';
13
+ import './transformer/TransformerService.js';
14
+ import '@omnicross/contracts/websearch-types';
15
+ import './ProviderProxy-vjt8sQQk.js';
package/dist/ports.js ADDED
File without changes