@openlimiter/core 0.4.0 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/dist/acquire/antigravity-probe.d.ts +139 -0
  2. package/dist/acquire/antigravity-probe.d.ts.map +1 -0
  3. package/dist/acquire/antigravity-probe.js +599 -0
  4. package/dist/acquire/antigravity-probe.js.map +1 -0
  5. package/dist/acquire/cadence.d.ts +74 -0
  6. package/dist/acquire/cadence.d.ts.map +1 -0
  7. package/dist/acquire/cadence.js +171 -0
  8. package/dist/acquire/cadence.js.map +1 -0
  9. package/dist/acquire/coordination.d.ts +157 -0
  10. package/dist/acquire/coordination.d.ts.map +1 -0
  11. package/dist/acquire/coordination.js +292 -0
  12. package/dist/acquire/coordination.js.map +1 -0
  13. package/dist/acquire/credentials.d.ts +113 -0
  14. package/dist/acquire/credentials.d.ts.map +1 -0
  15. package/dist/acquire/credentials.js +316 -0
  16. package/dist/acquire/credentials.js.map +1 -0
  17. package/dist/acquire/identity.d.ts +20 -0
  18. package/dist/acquire/identity.d.ts.map +1 -0
  19. package/dist/acquire/identity.js +20 -0
  20. package/dist/acquire/identity.js.map +1 -0
  21. package/dist/acquire/index.d.ts +10 -0
  22. package/dist/acquire/index.d.ts.map +1 -0
  23. package/dist/acquire/index.js +10 -0
  24. package/dist/acquire/index.js.map +1 -0
  25. package/dist/acquire/providers.d.ts +86 -0
  26. package/dist/acquire/providers.d.ts.map +1 -0
  27. package/dist/acquire/providers.js +175 -0
  28. package/dist/acquire/providers.js.map +1 -0
  29. package/dist/acquire/runner.d.ts +146 -0
  30. package/dist/acquire/runner.d.ts.map +1 -0
  31. package/dist/acquire/runner.js +345 -0
  32. package/dist/acquire/runner.js.map +1 -0
  33. package/dist/acquire/transport.d.ts +194 -0
  34. package/dist/acquire/transport.d.ts.map +1 -0
  35. package/dist/acquire/transport.js +434 -0
  36. package/dist/acquire/transport.js.map +1 -0
  37. package/dist/acquire/windows-credential.d.ts +74 -0
  38. package/dist/acquire/windows-credential.d.ts.map +1 -0
  39. package/dist/acquire/windows-credential.js +124 -0
  40. package/dist/acquire/windows-credential.js.map +1 -0
  41. package/dist/cache.d.ts +28 -0
  42. package/dist/cache.d.ts.map +1 -1
  43. package/dist/cache.js +179 -25
  44. package/dist/cache.js.map +1 -1
  45. package/dist/connection-state.d.ts +53 -2
  46. package/dist/connection-state.d.ts.map +1 -1
  47. package/dist/connection-state.js +98 -9
  48. package/dist/connection-state.js.map +1 -1
  49. package/dist/failures.d.ts +2 -1
  50. package/dist/failures.d.ts.map +1 -1
  51. package/dist/failures.js +7 -3
  52. package/dist/failures.js.map +1 -1
  53. package/dist/index.d.ts +1 -0
  54. package/dist/index.d.ts.map +1 -1
  55. package/dist/index.js +1 -0
  56. package/dist/index.js.map +1 -1
  57. package/dist/merge.d.ts.map +1 -1
  58. package/dist/merge.js +17 -1
  59. package/dist/merge.js.map +1 -1
  60. package/dist/normalizer.d.ts +2 -0
  61. package/dist/normalizer.d.ts.map +1 -1
  62. package/dist/normalizer.js +39 -4
  63. package/dist/normalizer.js.map +1 -1
  64. package/dist/types.d.ts +63 -1
  65. package/dist/types.d.ts.map +1 -1
  66. package/dist/types.js +22 -0
  67. package/dist/types.js.map +1 -1
  68. package/package.json +3 -2
@@ -0,0 +1,175 @@
1
+ import { claudeUsageRequest, codeAssistLoadRequest, codeAssistQuotaRequest, codexUsageRequest, grokBillingRequest, kimiUsageRequest, openrouterKeyRequest } from "./transport.js";
2
+ /**
3
+ * The sentence each row carries about how its number was obtained.
4
+ *
5
+ * Every one of these credentials was issued to somebody else's client. That is
6
+ * a thing a person is entitled to know before they rely on a bar, and it is the
7
+ * same thing every honest reader of these endpoints says, so it is said here
8
+ * once rather than implied.
9
+ */
10
+ export const ACQUISITION_DISCLOSURE = {
11
+ claude: "polls Anthropic with the token Claude Code stored on this machine, off " +
12
+ "unless you turn it on",
13
+ codex: "reads the login the Codex CLI stored, may break when OpenAI changes it",
14
+ gemini: "reads the login the Gemini CLI stored, may break when Google changes it",
15
+ antigravity: "reads the credential the Antigravity CLI stored, may break when Google " +
16
+ "changes it",
17
+ grok: "reads the login the Grok CLI stored, without the client marker xAI's own " +
18
+ "tool sends, so this request is verified on the first install that has a " +
19
+ "Grok login",
20
+ antigravityShared: "shared Google Code Assist quota from the Gemini CLI login, not " +
21
+ "Antigravity's own login",
22
+ kimi: "reads the login the Kimi CLI stored, may break when Moonshot changes it",
23
+ openrouter: "reads OpenRouter's documented key report with your own key"
24
+ };
25
+ /** What the Code Assist bootstrap calls the project the quota read is scoped to. */
26
+ export const CODE_ASSIST_PROJECT_FIELD = "cloudaicompanionProject";
27
+ /** The account label a reading taken from the shared Gemini login carries. */
28
+ export const SHARED_CODE_ASSIST_ACCOUNT = "gemini-cli-shared";
29
+ /** What a surface should print for that account instead of the identifier. */
30
+ export const SHARED_CODE_ASSIST_LABEL = "Shared Google Code Assist quota";
31
+ /** The list a bootstrap carries when it answered and withheld the project. */
32
+ export const CODE_ASSIST_TIERS_FIELD = "allowedTiers";
33
+ /**
34
+ * What the row says when Google withholds the companion project.
35
+ *
36
+ * Measured on 2026-09-07 on Lucas's own machine, read only: `loadCodeAssist`
37
+ * answered 200 to a request identifying as OpenLimiter and returned
38
+ * `allowedTiers` and `ineligibleTiers` and no `cloudaicompanionProject`, so
39
+ * there is nothing to scope the quota read to. The desktop reaches the same
40
+ * endpoint by claiming to be Google's own client
41
+ * (`apps/desktop/src-tauri/src/net.rs` 273 to 285 records exactly this), which
42
+ * Rule 1 forbids here. So the row states the fact rather than pretending the
43
+ * response was malformed.
44
+ *
45
+ * This conclusion is drawn ONLY from that measured signature. A day of silence
46
+ * bought on a guess would hide a provider that was merely having a bad
47
+ * afternoon, so anything else, a timeout, a 500, a rate limit, or a body that
48
+ * is not this, stays an ordinary transient failure on the ordinary cadence.
49
+ */
50
+ export const CODE_ASSIST_IDENTITY_SENTENCE = "Google answers this quota only to its own tools, so it is read here only " +
51
+ "when another tool on this machine has written it";
52
+ function isRecord(value) {
53
+ return typeof value === "object" && value !== null && !Array.isArray(value);
54
+ }
55
+ /**
56
+ * The two step Code Assist read, shared by Gemini CLI and Antigravity.
57
+ *
58
+ * The second step is scoped to the project the first one named. A bootstrap
59
+ * that names no project produces no request, which the runner reads as a shape
60
+ * this build did not understand rather than as a reason to ask anyway.
61
+ */
62
+ export function codeAssistSteps() {
63
+ return [
64
+ ({ credential }) => codeAssistLoadRequest(credential.secret),
65
+ ({ credential, previous }) => {
66
+ const bootstrap = previous[0];
67
+ /* Not an object at all is a shape this build does not understand. */
68
+ if (!isRecord(bootstrap))
69
+ return null;
70
+ const project = bootstrap[CODE_ASSIST_PROJECT_FIELD];
71
+ if (typeof project === "string") {
72
+ return codeAssistQuotaRequest(credential.secret, project);
73
+ }
74
+ /*
75
+ * The measured signature and nothing else: a tier list present, a project
76
+ * absent. That pairing is Google saying it knows who is asking and that
77
+ * this field is not for them, and it earns the day long backoff. A
78
+ * bootstrap missing BOTH fields is only a shape this build does not
79
+ * understand, and it stays drift on the ordinary cadence so a provider
80
+ * having a bad hour is never silenced for a day.
81
+ */
82
+ return Array.isArray(bootstrap[CODE_ASSIST_TIERS_FIELD])
83
+ ? { stop: "identity_refused" }
84
+ : null;
85
+ }
86
+ ];
87
+ }
88
+ /** The sentence overrides both Code Assist readers carry. */
89
+ const codeAssistSentences = {
90
+ identity_refused: CODE_ASSIST_IDENTITY_SENTENCE
91
+ };
92
+ export function claudeSpec(options) {
93
+ return {
94
+ provider: "CLAUDE",
95
+ credentialProvider: "CLAUDE",
96
+ steps: [({ credential }) => claudeUsageRequest(credential.secret)],
97
+ parse: options.parse,
98
+ disclosure: ACQUISITION_DISCLOSURE.claude,
99
+ enabled: options.enabled,
100
+ disabledReason: "the Anthropic poll is off, so this shows what Claude Code last reported"
101
+ };
102
+ }
103
+ export function codexSpec(parse) {
104
+ return {
105
+ provider: "CODEX",
106
+ credentialProvider: "CODEX",
107
+ steps: [
108
+ ({ credential }) => credential.accountId === null
109
+ ? null
110
+ : codexUsageRequest(credential.secret, credential.accountId)
111
+ ],
112
+ parse,
113
+ disclosure: ACQUISITION_DISCLOSURE.codex
114
+ };
115
+ }
116
+ export function geminiCliSpec(parse) {
117
+ return {
118
+ provider: "GEMINI_CLI",
119
+ credentialProvider: "GEMINI_CLI",
120
+ steps: codeAssistSteps(),
121
+ parse,
122
+ disclosure: ACQUISITION_DISCLOSURE.gemini,
123
+ outcomeSentence: codeAssistSentences
124
+ };
125
+ }
126
+ /** Whether this credential is the Gemini CLI's, borrowed for the shared quota. */
127
+ export function isSharedCodeAssist(credential) {
128
+ return credential.origin === "shared_code_assist";
129
+ }
130
+ export function antigravitySpec(parse) {
131
+ return {
132
+ provider: "ANTIGRAVITY",
133
+ credentialProvider: "ANTIGRAVITY",
134
+ steps: codeAssistSteps(),
135
+ parse,
136
+ disclosure: ACQUISITION_DISCLOSURE.antigravity,
137
+ outcomeSentence: codeAssistSentences,
138
+ /* A reading taken from the Gemini CLI's file is filed under its own account
139
+ label, so it can never be mistaken in the cache, on a bar or in a sync
140
+ for a login the person made to Antigravity. */
141
+ accountIdFor: (credential) => isSharedCodeAssist(credential) ? SHARED_CODE_ASSIST_ACCOUNT : null,
142
+ accountLabelFor: (credential) => isSharedCodeAssist(credential) ? SHARED_CODE_ASSIST_LABEL : null,
143
+ disclosureFor: (credential) => isSharedCodeAssist(credential) ? ACQUISITION_DISCLOSURE.antigravityShared : null
144
+ };
145
+ }
146
+ export function grokSpec(parse) {
147
+ return {
148
+ provider: "GROK",
149
+ credentialProvider: "GROK",
150
+ steps: [
151
+ ({ credential }) => grokBillingRequest(credential.secret, credential.accountId)
152
+ ],
153
+ parse,
154
+ disclosure: ACQUISITION_DISCLOSURE.grok
155
+ };
156
+ }
157
+ export function kimiSpec(parse) {
158
+ return {
159
+ provider: "KIMI",
160
+ credentialProvider: "KIMI",
161
+ steps: [({ credential }) => kimiUsageRequest(credential.secret)],
162
+ parse,
163
+ disclosure: ACQUISITION_DISCLOSURE.kimi
164
+ };
165
+ }
166
+ export function openrouterSpec(parse) {
167
+ return {
168
+ provider: "OPENROUTER",
169
+ credentialProvider: "OPENROUTER",
170
+ steps: [({ credential }) => openrouterKeyRequest(credential.secret)],
171
+ parse,
172
+ disclosure: ACQUISITION_DISCLOSURE.openrouter
173
+ };
174
+ }
175
+ //# sourceMappingURL=providers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"providers.js","sourceRoot":"","sources":["../../src/acquire/providers.ts"],"names":[],"mappings":"AAWA,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,sBAAsB,EACtB,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACrB,MAAM,gBAAgB,CAAC;AAOxB;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,MAAM,EACJ,yEAAyE;QACzE,uBAAuB;IACzB,KAAK,EAAE,wEAAwE;IAC/E,MAAM,EACJ,yEAAyE;IAC3E,WAAW,EACT,yEAAyE;QACzE,YAAY;IACd,IAAI,EACF,2EAA2E;QAC3E,0EAA0E;QAC1E,YAAY;IACd,iBAAiB,EACf,iEAAiE;QACjE,yBAAyB;IAC3B,IAAI,EAAE,yEAAyE;IAC/E,UAAU,EAAE,4DAA4D;CAChE,CAAC;AAEX,oFAAoF;AACpF,MAAM,CAAC,MAAM,yBAAyB,GAAG,yBAAyB,CAAC;AAEnE,8EAA8E;AAC9E,MAAM,CAAC,MAAM,0BAA0B,GAAG,mBAAmB,CAAC;AAE9D,8EAA8E;AAC9E,MAAM,CAAC,MAAM,wBAAwB,GAAG,iCAAiC,CAAC;AAE1E,8EAA8E;AAC9E,MAAM,CAAC,MAAM,uBAAuB,GAAG,cAAc,CAAC;AAEtD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,6BAA6B,GACxC,2EAA2E;IAC3E,kDAAkD,CAAC;AAErD,SAAS,QAAQ,CAAC,KAAc;IAC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,CAAC,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAAC,IAAI;QAClE,aAAa,EAAE,CAAC,UAAU,EAAE,EAAE,CAC5B,kBAAkB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,sBAAsB,CAAC,iBAAiB,CAAC,CAAC,CAAC,IAAI;KACnF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,KAAoB;IAC3C,OAAO;QACL,QAAQ,EAAE,MAAM;QAChB,kBAAkB,EAAE,MAAM;QAC1B,KAAK,EAAE;YACL,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,kBAAkB,CAAC,UAAU,CAAC,MAAM,EAAE,UAAU,CAAC,SAAS,CAAC;SAChF;QACD,KAAK;QACL,UAAU,EAAE,sBAAsB,CAAC,IAAI;KACxC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,KAAoB;IAC3C,OAAO;QACL,QAAQ,EAAE,MAAM;QAChB,kBAAkB,EAAE,MAAM;QAC1B,KAAK,EAAE,CAAC,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,gBAAgB,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QAChE,KAAK;QACL,UAAU,EAAE,sBAAsB,CAAC,IAAI;KACxC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,KAAoB;IACjD,OAAO;QACL,QAAQ,EAAE,YAAY;QACtB,kBAAkB,EAAE,YAAY;QAChC,KAAK,EAAE,CAAC,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,oBAAoB,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QACpE,KAAK;QACL,UAAU,EAAE,sBAAsB,CAAC,UAAU;KAC9C,CAAC;AACJ,CAAC"}
@@ -0,0 +1,146 @@
1
+ /**
2
+ * One round of acquisition: read what is on this machine, ask each provider
3
+ * once, and say plainly what happened to every one of them.
4
+ *
5
+ * The parsers are injected rather than imported. This package sits underneath
6
+ * the connector package that owns them, and inverting that dependency to save
7
+ * one argument would put a provider response shape in the same module as the
8
+ * cache. So a caller wires its parsers in, and this file stays about cadence,
9
+ * ordering and honesty.
10
+ *
11
+ * Nothing here throws. A round that fails every provider still returns a row
12
+ * per provider saying why, because the surfaces above are a status line and a
13
+ * doctor command, and both of them owe a person an answer rather than a stack.
14
+ */
15
+ import type { CollectionFailureReason, CollectionReport } from "../collection.js";
16
+ import type { ProviderCode, RawMeter } from "../types.js";
17
+ import { type AcquisitionSchedule } from "./cadence.js";
18
+ import { type AcquiredCredential, type AcquisitionProvider, type CredentialLookupOptions, type CredentialResult } from "./credentials.js";
19
+ import { type AcquisitionOutcome, type AcquisitionRequest, type AcquisitionTransport } from "./transport.js";
20
+ import { type AntigravityProbeOptions, type AntigravityProbeResult } from "./antigravity-probe.js";
21
+ export interface AcquisitionStepContext {
22
+ readonly credential: AcquiredCredential;
23
+ /** The parsed bodies of the steps already taken, oldest first. */
24
+ readonly previous: readonly unknown[];
25
+ }
26
+ /**
27
+ * What a step decided to do.
28
+ *
29
+ * A request is the ordinary answer. `stop` is how a step reports an outcome it
30
+ * can name precisely, which is what tells a bootstrap that answered 200 and
31
+ * withheld the field the next hop needs apart from a bootstrap that arrived
32
+ * mangled. Null remains the honest "I do not understand this".
33
+ */
34
+ export type AcquisitionStepResult = AcquisitionRequest | {
35
+ readonly stop: AcquisitionOutcome;
36
+ };
37
+ /**
38
+ * One request in a provider's read.
39
+ *
40
+ * Most providers have exactly one. The Code Assist pair has two, because the
41
+ * first answers with the companion project the second has to be scoped to.
42
+ */
43
+ export type AcquisitionStep = (context: AcquisitionStepContext) => AcquisitionStepResult | null;
44
+ export interface AcquisitionSpec {
45
+ /** The provider code the resulting rows carry. */
46
+ readonly provider: ProviderCode;
47
+ /** Whose stored credential this read uses. Antigravity borrows Gemini's file. */
48
+ readonly credentialProvider: AcquisitionProvider;
49
+ readonly steps: readonly AcquisitionStep[];
50
+ /** The connector parser for this provider's response, injected by the caller. */
51
+ readonly parse: (payload: unknown, now: string) => readonly RawMeter[] | null;
52
+ /**
53
+ * The one sentence this provider's row always carries, or null.
54
+ *
55
+ * Used where the way we read a provider is itself something a person should
56
+ * know, which is every provider whose credential belongs to somebody else's
57
+ * client.
58
+ */
59
+ readonly disclosure: string | null;
60
+ /** False when a configuration switch turns this provider's poll off. */
61
+ readonly enabled?: boolean;
62
+ /** Why it is off, in the words the row prints. */
63
+ readonly disabledReason?: string;
64
+ /**
65
+ * The account label these rows carry, when the credential decides it.
66
+ *
67
+ * Antigravity is the reason this exists. Reading the Gemini CLI's file is a
68
+ * legitimate way to reach the shared Code Assist quota, and it is not
69
+ * Antigravity's own login, so the rows are filed under an account that says
70
+ * which it was rather than under the provider's unnamed default.
71
+ */
72
+ readonly accountIdFor?: (credential: AcquiredCredential) => string | null;
73
+ /** The disclosure these rows carry, when the credential changes it. */
74
+ readonly disclosureFor?: (credential: AcquiredCredential) => string | null;
75
+ /** The human name for that account, for a surface that would print an id. */
76
+ readonly accountLabelFor?: (credential: AcquiredCredential) => string | null;
77
+ /** Sentences this provider says better than the shared vocabulary does. */
78
+ readonly outcomeSentence?: Partial<Record<AcquisitionOutcome, string>>;
79
+ }
80
+ /** What one provider's row says after a round. */
81
+ export type AcquisitionStatus = "read" | "stale" | "waiting" | "not_detected" | "off";
82
+ export interface AcquisitionRow {
83
+ readonly provider: ProviderCode;
84
+ /** The account these rows were filed under, when one was decided. */
85
+ readonly accountId?: string;
86
+ /** Whether a local credential for this provider was found at all. */
87
+ readonly detected: boolean;
88
+ readonly status: AcquisitionStatus;
89
+ /** Why the row is not `read`, in a sentence with no dashes. */
90
+ readonly reason: string | null;
91
+ /** The earliest instant this provider will be asked again, when one is set. */
92
+ readonly nextAttemptAt: string | null;
93
+ readonly disclosure: string | null;
94
+ }
95
+ export interface AcquisitionRunResult {
96
+ readonly rows: readonly AcquisitionRow[];
97
+ /** Only the successful reads. A failure never rewrites the cache. */
98
+ readonly reports: readonly CollectionReport[];
99
+ readonly schedule: AcquisitionSchedule;
100
+ }
101
+ export interface AcquisitionRunOptions {
102
+ readonly transport: AcquisitionTransport;
103
+ readonly now: string;
104
+ readonly schedule: AcquisitionSchedule;
105
+ /** Where credentials are read from, injected so a test never reads a real one. */
106
+ readonly readCredential?: (provider: AcquisitionProvider) => Promise<CredentialResult>;
107
+ readonly lookup?: CredentialLookupOptions;
108
+ /**
109
+ * What is stamped onto every meter before it is validated.
110
+ *
111
+ * Provenance and the writer marker are facts about HOW a reading arrived, and
112
+ * only the command that ran the round knows them, so they are applied here
113
+ * rather than invented by a parser.
114
+ */
115
+ readonly stamp?: (meters: readonly RawMeter[], credential: AcquiredCredential) => readonly RawMeter[];
116
+ readonly probeAntigravity?: (options?: AntigravityProbeOptions) => Promise<AntigravityProbeResult>;
117
+ /**
118
+ * How the Antigravity probe turns a pid into the executable path it checks
119
+ * against the trusted install roots. Threaded through from here rather than
120
+ * left to the probe's own untrusted fallback, so a caller that wants a
121
+ * verified reading always gets one: see `resolveAgyExecutablePath`.
122
+ */
123
+ readonly resolveExecutablePath?: (pid: string) => Promise<string | null>;
124
+ }
125
+ /**
126
+ * The failure vocabulary the cache understands, from ours.
127
+ *
128
+ * Drift is deliberately NOT mapped through. In this codebase a drift report
129
+ * suppresses every cached row for that provider, and the command line tool is
130
+ * a second reader beside a status line that already writes Claude rows. A free
131
+ * account whose usage document carries no windows would parse to nothing and
132
+ * would then withdraw rows another source had every right to write. A failed
133
+ * read leaves the cache exactly as it was and the row says what happened; only
134
+ * a successful read changes anything.
135
+ */
136
+ export declare function collectionReasonFor(outcome: AcquisitionOutcome): CollectionFailureReason;
137
+ /**
138
+ * Run every spec once, honouring the schedule.
139
+ *
140
+ * The returned schedule is the one to persist. A provider that was not asked,
141
+ * because it is off or because nothing on this machine belongs to it, keeps the
142
+ * schedule it had: a person who installs Codex this afternoon should not have
143
+ * to wait out a backoff that was recorded before Codex existed here.
144
+ */
145
+ export declare function runAcquisition(specs: readonly AcquisitionSpec[], options: AcquisitionRunOptions): Promise<AcquisitionRunResult>;
146
+ //# sourceMappingURL=runner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../src/acquire/runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EACV,uBAAuB,EACvB,gBAAgB,EACjB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAY,MAAM,aAAa,CAAC;AACpE,OAAO,EAKL,KAAK,mBAAmB,EACzB,MAAM,cAAc,CAAC;AACtB,OAAO,EAGL,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,KAAK,uBAAuB,EAC5B,KAAK,gBAAgB,EACtB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAEL,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EAC1B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAEL,KAAK,uBAAuB,EAC5B,KAAK,sBAAsB,EAC5B,MAAM,wBAAwB,CAAC;AAGhC,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,UAAU,EAAE,kBAAkB,CAAC;IACxC,kEAAkE;IAClE,QAAQ,CAAC,QAAQ,EAAE,SAAS,OAAO,EAAE,CAAC;CACvC;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,qBAAqB,GAC7B,kBAAkB,GAClB;IAAE,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAA;CAAE,CAAC;AAE1C;;;;;GAKG;AACH,MAAM,MAAM,eAAe,GAAG,CAC5B,OAAO,EAAE,sBAAsB,KAC5B,qBAAqB,GAAG,IAAI,CAAC;AAElC,MAAM,WAAW,eAAe;IAC9B,kDAAkD;IAClD,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC;IAChC,iFAAiF;IACjF,QAAQ,CAAC,kBAAkB,EAAE,mBAAmB,CAAC;IACjD,QAAQ,CAAC,KAAK,EAA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