@omnicross/core 0.2.0 → 0.2.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.
- package/LICENSE +21 -21
- package/NOTICE +57 -57
- package/README.md +22 -22
- package/dist/{BuiltinToolExecutor-CS2WpXhM.d.cts → BuiltinToolExecutor-BHgH-EaZ.d.cts} +25 -2
- package/dist/{BuiltinToolExecutor-BluWyeob.d.ts → BuiltinToolExecutor-Bi1LmiTP.d.ts} +25 -2
- package/dist/{CompletionService-BiJqftc-.d.cts → CompletionService-BniP7j88.d.cts} +2 -2
- package/dist/{CompletionService-NXN_Av5W.d.ts → CompletionService-BqrKPwfA.d.ts} +2 -2
- package/dist/{ProviderProxy-CgIcCVwk.d.cts → ProviderProxy-Bz_nkOwq.d.cts} +1 -1
- package/dist/{ProviderProxy-DYoY5XoT.d.ts → ProviderProxy-Ckr6oTrE.d.ts} +1 -1
- package/dist/auth/GeminiCodeAssistProjectResolver.cjs +2 -2
- package/dist/auth/GeminiCodeAssistProjectResolver.js +1 -1
- package/dist/{chunk-FJNKXOWE.js → chunk-2C3TTBS7.js} +4 -4
- package/dist/{chunk-OST5RJOJ.cjs → chunk-4Z3ZLLC2.cjs} +13 -7
- package/dist/chunk-7RJI3NDI.cjs +236 -0
- package/dist/chunk-D4WNI6BR.cjs +386 -0
- package/dist/chunk-DBBR6RHF.js +236 -0
- package/dist/chunk-E4QHVXV5.cjs +118 -0
- package/dist/chunk-HL2YSPL7.cjs +673 -0
- package/dist/chunk-LFPQ2OVH.js +386 -0
- package/dist/{chunk-WSJE42SG.js → chunk-LKDAN4D7.js} +3684 -2462
- package/dist/{chunk-DEIUR2TH.js → chunk-LQYS2N47.js} +12 -8
- package/dist/{chunk-NZYN7C3P.cjs → chunk-MPXOKQJP.cjs} +53 -53
- package/dist/chunk-MZEGQSKQ.js +118 -0
- package/dist/chunk-NLUOTJWB.js +673 -0
- package/dist/{chunk-CTKM773J.cjs → chunk-UPQIWJIE.cjs} +12 -8
- package/dist/{chunk-CFSGYFOZ.js → chunk-VL5TUDTM.js} +7 -1
- package/dist/{chunk-7B56AJBB.cjs → chunk-VSYQ6XYN.cjs} +2233 -1011
- package/dist/{chunk-CDHS2QDC.js → chunk-Y4CRNHJO.js} +53 -53
- package/dist/{chunk-TVYA5JSQ.cjs → chunk-ZAPN7XA6.cjs} +5 -5
- package/dist/completion/BuiltinToolExecutor.cjs +2 -2
- package/dist/completion/BuiltinToolExecutor.d.cts +3 -1
- package/dist/completion/BuiltinToolExecutor.d.ts +3 -1
- package/dist/completion/BuiltinToolExecutor.js +1 -1
- package/dist/completion/CompletionService.cjs +11 -10
- package/dist/completion/CompletionService.d.cts +6 -3
- package/dist/completion/CompletionService.d.ts +6 -3
- package/dist/completion/CompletionService.js +10 -9
- package/dist/completion.cjs +11 -10
- package/dist/completion.d.cts +6 -3
- package/dist/completion.d.ts +6 -3
- package/dist/completion.js +10 -9
- package/dist/egress-I46O_p5L.d.cts +126 -0
- package/dist/egress-I46O_p5L.d.ts +126 -0
- package/dist/frontends-Doz0RaWu.d.cts +97 -0
- package/dist/frontends-Doz0RaWu.d.ts +97 -0
- package/dist/image-generation.cjs +2 -2
- package/dist/image-generation.d.cts +7 -4
- package/dist/image-generation.d.ts +7 -4
- package/dist/image-generation.js +1 -1
- package/dist/index.cjs +25 -10
- package/dist/index.d.cts +12 -8
- package/dist/index.d.ts +12 -8
- package/dist/index.js +24 -9
- package/dist/openai-operation.d.cts +4 -1
- package/dist/openai-operation.d.ts +4 -1
- package/dist/outbound-api/routeResolver.d.cts +9 -5
- package/dist/outbound-api/routeResolver.d.ts +9 -5
- package/dist/outbound-api/subscriptionRegistryPort.d.cts +4 -1
- package/dist/outbound-api/subscriptionRegistryPort.d.ts +4 -1
- package/dist/outbound-api/types.d.cts +8 -4
- package/dist/outbound-api/types.d.ts +8 -4
- package/dist/outbound-api.cjs +25 -10
- package/dist/outbound-api.d.cts +117 -8
- package/dist/outbound-api.d.ts +117 -8
- package/dist/outbound-api.js +24 -9
- package/dist/pipeline/AccountAllowanceScheduling.d.cts +8 -4
- package/dist/pipeline/AccountAllowanceScheduling.d.ts +8 -4
- package/dist/pipeline/upstreamFetch.cjs +2 -2
- package/dist/pipeline/upstreamFetch.js +1 -1
- package/dist/ports.d.cts +8 -4
- package/dist/ports.d.ts +8 -4
- package/dist/provider-proxy/ProviderProxy.cjs +11 -10
- package/dist/provider-proxy/ProviderProxy.d.cts +5 -2
- package/dist/provider-proxy/ProviderProxy.d.ts +5 -2
- package/dist/provider-proxy/ProviderProxy.js +10 -9
- package/dist/provider-proxy/ingress/providerProxyShared.cjs +13 -10
- package/dist/provider-proxy/ingress/providerProxyShared.d.cts +22 -3
- package/dist/provider-proxy/ingress/providerProxyShared.d.ts +22 -3
- package/dist/provider-proxy/ingress/providerProxyShared.js +12 -9
- package/dist/provider-proxy/types.d.cts +4 -1
- package/dist/provider-proxy/types.d.ts +4 -1
- package/dist/provider-proxy.cjs +11 -10
- package/dist/provider-proxy.d.cts +10 -6
- package/dist/provider-proxy.d.ts +10 -6
- package/dist/provider-proxy.js +10 -9
- package/dist/proxy-UZTtjPZx.d.cts +18 -0
- package/dist/proxy-UZTtjPZx.d.ts +18 -0
- package/dist/{routeResolver-rpKQLyDO.d.cts → routeResolver-Da0yvkL1.d.cts} +2 -2
- package/dist/{routeResolver-CTCcSHWu.d.ts → routeResolver-STwMz_G4.d.ts} +2 -2
- package/dist/runtime-6QXNU526.cjs +8 -0
- package/dist/runtime-M5WXLD2R.js +8 -0
- package/dist/runtime-t8AZacFF.d.cts +233 -0
- package/dist/runtime-t8AZacFF.d.ts +233 -0
- package/dist/search/api.cjs +761 -0
- package/dist/search/api.d.cts +370 -0
- package/dist/search/api.d.ts +370 -0
- package/dist/search/api.js +761 -0
- package/dist/search/http.cjs +37 -0
- package/dist/search/http.d.cts +269 -0
- package/dist/search/http.d.ts +269 -0
- package/dist/search/http.js +37 -0
- package/dist/search.cjs +57 -0
- package/dist/search.d.cts +113 -0
- package/dist/search.d.ts +113 -0
- package/dist/search.js +57 -0
- package/dist/transformer/transformers/AnthropicTransformer.cjs +3 -3
- package/dist/transformer/transformers/AnthropicTransformer.js +2 -2
- package/dist/transformer/transformers.cjs +7 -7
- package/dist/transformer/transformers.js +6 -6
- package/dist/transformer.cjs +6 -6
- package/dist/transformer.js +5 -5
- package/dist/{types-DsHBBk3h.d.cts → types-BSIJdsyl.d.cts} +15 -0
- package/dist/{types-CbglB73l.d.cts → types-Be-yt_6T.d.cts} +1 -1
- package/dist/{types-CVRge76p.d.ts → types-By9Tg6-I.d.ts} +15 -0
- package/dist/types-CbCZqLGg.d.cts +127 -0
- package/dist/types-CbCZqLGg.d.ts +127 -0
- package/dist/{types-jjU24eYG.d.cts → types-D-oHYusb.d.cts} +73 -4
- package/dist/{types-Bd72H4SB.d.ts → types-Dm4_36V4.d.ts} +1 -1
- package/dist/{types-5T223WYQ.d.ts → types-Dvlpjn0d.d.ts} +73 -4
- package/package.json +5 -3
- package/dist/{chunk-6OC3ORW6.js → chunk-EUZRH544.js} +3 -3
- package/dist/{chunk-SQMAEDNE.cjs → chunk-POUTD5AM.cjs} +2 -2
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import { SearchProviderContribution, SearchContributionContext, SearchProviderId, SearchPolicy, SearchRuntimeEvent, SearchRequest, OrchestratedSearchResponse, SearchProviderDescriptor } from '@omnicross/contracts/search-types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The search provider registry — one place that knows which providers exist.
|
|
5
|
+
*
|
|
6
|
+
* Registration is by CONTRIBUTION, not by class: a provider arrives with its
|
|
7
|
+
* `source` and `kind` declared, so nothing downstream has to guess a trust
|
|
8
|
+
* boundary from an id's spelling. That is what makes this registry usable by a
|
|
9
|
+
* Phase-2 host unchanged — Elftia's `local-*` providers register through the
|
|
10
|
+
* same call an Omnicross builtin does, with `source: 'host'` stated.
|
|
11
|
+
*
|
|
12
|
+
* Two rules worth stating out loud:
|
|
13
|
+
*
|
|
14
|
+
* 1. **Registration failures are NOT search failures.** They throw
|
|
15
|
+
* {@link SearchRegistryError}, a plain `Error`, never a
|
|
16
|
+
* `SearchProviderError`. The eight-code taxonomy exists so a fallback policy
|
|
17
|
+
* can decide what to do next; a duplicate id is a wiring bug with no "next"
|
|
18
|
+
* to decide on, and letting it wear a taxonomy code would teach the
|
|
19
|
+
* orchestrator to fall back from a programming error.
|
|
20
|
+
* 2. **Ordering lives here, once.** `list()` is the single answer to "in what
|
|
21
|
+
* order do providers come?", which is the scattered decision plan 阶段3
|
|
22
|
+
* exists to consolidate.
|
|
23
|
+
*
|
|
24
|
+
* @module search/registry
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* A registration was rejected.
|
|
29
|
+
*
|
|
30
|
+
* Deliberately not a `SearchProviderError`: see rule 1 in the module doc.
|
|
31
|
+
*/
|
|
32
|
+
declare class SearchRegistryError extends Error {
|
|
33
|
+
constructor(message: string);
|
|
34
|
+
}
|
|
35
|
+
/** Construction-time registry policy. */
|
|
36
|
+
interface SearchProviderRegistryOptions {
|
|
37
|
+
/**
|
|
38
|
+
* Allow a `source: 'host'` contribution to replace a registered
|
|
39
|
+
* `source: 'builtin'` one.
|
|
40
|
+
*
|
|
41
|
+
* Default `false` — plan §7.2's default-deny. This is the admin-policy
|
|
42
|
+
* escape hatch, not a convenience: shadowing a builtin silently changes where
|
|
43
|
+
* a user's queries are sent.
|
|
44
|
+
*/
|
|
45
|
+
allowBuiltinOverride?: boolean;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The registered providers, ordered.
|
|
49
|
+
*
|
|
50
|
+
* Not a singleton: a runtime owns one. Tests, hosts, and future multi-tenant
|
|
51
|
+
* assemblies each get their own without global state to reset.
|
|
52
|
+
*/
|
|
53
|
+
declare class SearchProviderRegistry {
|
|
54
|
+
private readonly entries;
|
|
55
|
+
private readonly allowBuiltinOverride;
|
|
56
|
+
private nextSequence;
|
|
57
|
+
constructor(options?: SearchProviderRegistryOptions);
|
|
58
|
+
/**
|
|
59
|
+
* Register one provider.
|
|
60
|
+
*
|
|
61
|
+
* @param contribution - the provider with its origin, transport, and
|
|
62
|
+
* capabilities declared.
|
|
63
|
+
* @param context - who is registering, for a Phase-2 host. Retained as-is;
|
|
64
|
+
* no rule reads it today, and the parameter exists so adding one later is
|
|
65
|
+
* not a signature change for every caller.
|
|
66
|
+
* @throws {SearchRegistryError} on a blank id, a duplicate id, or a host
|
|
67
|
+
* contribution colliding with a builtin without `allowBuiltinOverride`.
|
|
68
|
+
*/
|
|
69
|
+
register(contribution: SearchProviderContribution, context?: SearchContributionContext): void;
|
|
70
|
+
/** Whether an id is currently registered. */
|
|
71
|
+
has(id: SearchProviderId): boolean;
|
|
72
|
+
/** The contribution registered under `id`, if any. */
|
|
73
|
+
get(id: SearchProviderId): SearchProviderContribution | undefined;
|
|
74
|
+
/**
|
|
75
|
+
* Remove a provider.
|
|
76
|
+
*
|
|
77
|
+
* The Phase-2 host-disconnect hook: when a host goes away its contributions
|
|
78
|
+
* go with it, and the id becomes free to register again.
|
|
79
|
+
*
|
|
80
|
+
* @returns whether something was removed.
|
|
81
|
+
*/
|
|
82
|
+
unregister(id: SearchProviderId): boolean;
|
|
83
|
+
/**
|
|
84
|
+
* Every registered contribution, in candidate order.
|
|
85
|
+
*
|
|
86
|
+
* `priorityHint` ascending; contributions without a hint come AFTER every
|
|
87
|
+
* hinted one (an absent hint is "no opinion", not "highest priority"); ties
|
|
88
|
+
* keep registration order. The builtin HTTP contributions carry no hints, so
|
|
89
|
+
* today this is exactly registration order.
|
|
90
|
+
*/
|
|
91
|
+
list(): SearchProviderContribution[];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* The search orchestrator — the ONE fallback implementation in Omnicross.
|
|
96
|
+
*
|
|
97
|
+
* Before this module the repo had three provider orders (the host orchestrator,
|
|
98
|
+
* the HTTP-only service, and `BuiltinToolExecutor`'s own list), which is how a
|
|
99
|
+
* query could be sent to a provider twice, or to one a policy meant to exclude.
|
|
100
|
+
* Plan 阶段3's exit condition is that exactly one implementation decides which
|
|
101
|
+
* provider runs next, and that no request ever falls back twice. Both are
|
|
102
|
+
* structural here: consumers submit ONE request and get one answer, with no
|
|
103
|
+
* loop of their own.
|
|
104
|
+
*
|
|
105
|
+
* The semantics that are easy to get wrong, stated plainly:
|
|
106
|
+
*
|
|
107
|
+
* - **An empty result set is a SUCCESS.** A provider that returns `[]` has
|
|
108
|
+
* already walked its own candidates and is reporting "nothing found". Treating
|
|
109
|
+
* that as a failure would re-conflate the empty-vs-broken distinction 阶段2
|
|
110
|
+
* built, so it ends the walk. (A deliberate divergence from Elftia, which
|
|
111
|
+
* continues to the next provider on zero results — recorded for 阶段5's
|
|
112
|
+
* allowed-differences list.)
|
|
113
|
+
* - **A pinned provider never falls back.** `request.provider` is a caller's
|
|
114
|
+
* explicit choice; silently trying someone else would send the query
|
|
115
|
+
* somewhere it was not authorized to go, and would be the second fallback in
|
|
116
|
+
* a caller that has its own.
|
|
117
|
+
* - **Cancellation ends everything immediately.** It is the caller's decision,
|
|
118
|
+
* not a provider failure, and must never spend another candidate.
|
|
119
|
+
*
|
|
120
|
+
* Observability is emitted here because this is where attempts happen, and it
|
|
121
|
+
* carries a query HASH only — plan §11.3. No event field can hold query text, a
|
|
122
|
+
* URL, or result content.
|
|
123
|
+
*
|
|
124
|
+
* @module search/orchestrator
|
|
125
|
+
*/
|
|
126
|
+
|
|
127
|
+
/** Receives runtime events. Exceptions from it are swallowed, never propagated. */
|
|
128
|
+
type SearchRuntimeEventListener = (event: SearchRuntimeEvent) => void;
|
|
129
|
+
/** Construction-time orchestrator configuration. */
|
|
130
|
+
interface SearchOrchestratorOptions {
|
|
131
|
+
/** Default policy for every search; a per-call policy overrides it field by field. */
|
|
132
|
+
policy?: SearchPolicy;
|
|
133
|
+
/** Observability sink (plan §11.3). */
|
|
134
|
+
onEvent?: SearchRuntimeEventListener;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* A short, one-way key for correlating the events of one query.
|
|
138
|
+
*
|
|
139
|
+
* Truncated deliberately: enough to group events, far too little to attack the
|
|
140
|
+
* preimage of a full query with, and the events channel is the one place a
|
|
141
|
+
* query must never appear in the clear.
|
|
142
|
+
*/
|
|
143
|
+
declare function hashSearchQuery(query: string): string;
|
|
144
|
+
declare class SearchOrchestrator {
|
|
145
|
+
private readonly registry;
|
|
146
|
+
private readonly defaultPolicy;
|
|
147
|
+
private readonly onEvent?;
|
|
148
|
+
constructor(registry: SearchProviderRegistry, options?: SearchOrchestratorOptions);
|
|
149
|
+
/**
|
|
150
|
+
* Run one search.
|
|
151
|
+
*
|
|
152
|
+
* @param request - the query, an optional pinned provider, and per-request
|
|
153
|
+
* options. `options` is passed to the provider untouched: providers own
|
|
154
|
+
* their own timeouts and the orchestrator adds no second timeout layer.
|
|
155
|
+
* @param policyOverride - per-request policy, merged field-by-field over the
|
|
156
|
+
* orchestrator's default.
|
|
157
|
+
* @throws {SearchProviderError} when no provider produced a response.
|
|
158
|
+
*/
|
|
159
|
+
search(request: SearchRequest, policyOverride?: SearchPolicy): Promise<OrchestratedSearchResponse>;
|
|
160
|
+
/** Resolve the candidate list for one request. */
|
|
161
|
+
private planCandidates;
|
|
162
|
+
/** Deliver one event. A listener that throws must never fail a search. */
|
|
163
|
+
private emit;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* `SearchRuntime` — the one high-level entry for search in Omnicross.
|
|
168
|
+
*
|
|
169
|
+
* Everything above this line (阶段5's protocol frontends, the daemon, and in
|
|
170
|
+
* Phase 2 the embedding host) calls `search`, `registerContribution`, and
|
|
171
|
+
* `listProviders`; nothing above it builds a provider chain, because the moment
|
|
172
|
+
* two callers can, the fallback order is scattered again. That is the whole
|
|
173
|
+
* point of plan 阶段3.
|
|
174
|
+
*
|
|
175
|
+
* The facade is thin on purpose — a registry, an orchestrator, and the wiring
|
|
176
|
+
* between them. Policy arrives as an argument (runtime default here,
|
|
177
|
+
* per-request pinning on the request); nothing in this module reads a config
|
|
178
|
+
* file or a user setting, which keeps "where does policy come from?" a 阶段5
|
|
179
|
+
* assembly question rather than a contract baked in now.
|
|
180
|
+
*
|
|
181
|
+
* @module search/runtime
|
|
182
|
+
*/
|
|
183
|
+
|
|
184
|
+
/** How a runtime is assembled. Every field has a documented default. */
|
|
185
|
+
interface SearchRuntimeOptions {
|
|
186
|
+
/**
|
|
187
|
+
* Providers to register at construction.
|
|
188
|
+
*
|
|
189
|
+
* Defaults to {@link builtinHttpSearchContributions} — the two keyless HTTP
|
|
190
|
+
* engines. Pass an explicit list (including an empty one) to build a runtime
|
|
191
|
+
* that has only what the caller supplies.
|
|
192
|
+
*/
|
|
193
|
+
contributions?: SearchProviderContribution[];
|
|
194
|
+
/** Default policy for every search. Defaults to fallback on, all allowed, unbounded. */
|
|
195
|
+
policy?: SearchPolicy;
|
|
196
|
+
/** Observability listener; receives events carrying a query hash, never a query. */
|
|
197
|
+
onEvent?: SearchRuntimeEventListener;
|
|
198
|
+
/** Let a host contribution replace a builtin one. Default-deny, per plan §7.2. */
|
|
199
|
+
allowBuiltinOverride?: boolean;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* The search entry point.
|
|
203
|
+
*
|
|
204
|
+
* Search, registration, and capability discovery in one object, so a consumer
|
|
205
|
+
* never needs a reference to the registry or the orchestrator underneath.
|
|
206
|
+
*/
|
|
207
|
+
interface SearchRuntime {
|
|
208
|
+
/**
|
|
209
|
+
* Run one search.
|
|
210
|
+
*
|
|
211
|
+
* @throws {SearchProviderError} when no provider produced a response. An
|
|
212
|
+
* empty `results` array is a SUCCESS — a provider reporting that it found
|
|
213
|
+
* nothing, which is a different answer from failing to look.
|
|
214
|
+
*/
|
|
215
|
+
search(request: SearchRequest): Promise<OrchestratedSearchResponse>;
|
|
216
|
+
/** Add a provider (the Phase-2 host registration path). */
|
|
217
|
+
registerContribution(contribution: SearchProviderContribution, context?: SearchContributionContext): void;
|
|
218
|
+
/** Remove a provider; returns whether one was removed. */
|
|
219
|
+
unregisterContribution(id: SearchProviderId): boolean;
|
|
220
|
+
/** Serializable descriptors of every registered provider, in candidate order. */
|
|
221
|
+
listProviders(): SearchProviderDescriptor[];
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Build a runtime.
|
|
225
|
+
*
|
|
226
|
+
* Defaults to the builtin HTTP providers with an unrestricted policy: the
|
|
227
|
+
* deliberate 阶段3 stance, since a sensitive default (one provider, egress
|
|
228
|
+
* restricted) only becomes meaningful once user-facing configuration exists to
|
|
229
|
+
* express the choice. Both are reachable today through {@link SearchPolicy}.
|
|
230
|
+
*/
|
|
231
|
+
declare function createSearchRuntime(options?: SearchRuntimeOptions): SearchRuntime;
|
|
232
|
+
|
|
233
|
+
export { type SearchRuntime as S, SearchOrchestrator as a, type SearchOrchestratorOptions as b, SearchProviderRegistry as c, type SearchProviderRegistryOptions as d, SearchRegistryError as e, type SearchRuntimeEventListener as f, type SearchRuntimeOptions as g, createSearchRuntime as h, hashSearchQuery as i };
|