apcore-a2a 0.5.0 → 0.7.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 (57) hide show
  1. package/README.md +72 -1
  2. package/dist/adapters/card-visibility.d.ts +148 -0
  3. package/dist/adapters/card-visibility.d.ts.map +1 -0
  4. package/dist/adapters/card-visibility.js +237 -0
  5. package/dist/adapters/card-visibility.js.map +1 -0
  6. package/dist/adapters/errors.d.ts +39 -4
  7. package/dist/adapters/errors.d.ts.map +1 -1
  8. package/dist/adapters/errors.js +89 -7
  9. package/dist/adapters/errors.js.map +1 -1
  10. package/dist/adapters/skill-mapper.d.ts +27 -0
  11. package/dist/adapters/skill-mapper.d.ts.map +1 -1
  12. package/dist/adapters/skill-mapper.js +61 -0
  13. package/dist/adapters/skill-mapper.js.map +1 -1
  14. package/dist/cli.d.ts +63 -0
  15. package/dist/cli.d.ts.map +1 -1
  16. package/dist/cli.js +279 -38
  17. package/dist/cli.js.map +1 -1
  18. package/dist/client/client.d.ts.map +1 -1
  19. package/dist/client/client.js +16 -1
  20. package/dist/client/client.js.map +1 -1
  21. package/dist/client/exceptions.d.ts +31 -0
  22. package/dist/client/exceptions.d.ts.map +1 -1
  23. package/dist/client/exceptions.js +40 -0
  24. package/dist/client/exceptions.js.map +1 -1
  25. package/dist/client/index.d.ts +1 -1
  26. package/dist/client/index.d.ts.map +1 -1
  27. package/dist/client/index.js +1 -1
  28. package/dist/client/index.js.map +1 -1
  29. package/dist/config.d.ts +38 -0
  30. package/dist/config.d.ts.map +1 -0
  31. package/dist/config.js +71 -0
  32. package/dist/config.js.map +1 -0
  33. package/dist/index.d.ts +4 -1
  34. package/dist/index.d.ts.map +1 -1
  35. package/dist/index.js +5 -1
  36. package/dist/index.js.map +1 -1
  37. package/dist/openapi-backend.d.ts +203 -0
  38. package/dist/openapi-backend.d.ts.map +1 -0
  39. package/dist/openapi-backend.js +453 -0
  40. package/dist/openapi-backend.js.map +1 -0
  41. package/dist/serve.d.ts +12 -0
  42. package/dist/serve.d.ts.map +1 -1
  43. package/dist/serve.js +1 -0
  44. package/dist/serve.js.map +1 -1
  45. package/dist/server/context.d.ts +12 -1
  46. package/dist/server/context.d.ts.map +1 -1
  47. package/dist/server/context.js +14 -0
  48. package/dist/server/context.js.map +1 -1
  49. package/dist/server/executor.d.ts +8 -0
  50. package/dist/server/executor.d.ts.map +1 -1
  51. package/dist/server/executor.js +41 -9
  52. package/dist/server/executor.js.map +1 -1
  53. package/dist/server/factory.d.ts +12 -0
  54. package/dist/server/factory.d.ts.map +1 -1
  55. package/dist/server/factory.js +133 -25
  56. package/dist/server/factory.js.map +1 -1
  57. package/package.json +4 -3
@@ -2,8 +2,57 @@ import { ErrorCodes } from "apcore-js";
2
2
  const CODE_METHOD_NOT_FOUND = -32601;
3
3
  const CODE_INVALID_PARAMS = -32602;
4
4
  const CODE_INTERNAL_ERROR = -32603;
5
- const CODE_TASK_NOT_FOUND = -32001;
5
+ /**
6
+ * A2A 1.0 `TaskNotFoundError`. Reserved for an unknown task id or one owned by
7
+ * another principal — deliberately indistinguishable from each other, and no
8
+ * longer produced for an authorization refusal (see {@link CODE_ACCESS_DENIED}).
9
+ */
10
+ export const CODE_TASK_NOT_FOUND = -32001;
11
+ // Governance refusal codes (srs FR-ERR-003 / FR-ERR-009 / FR-ERR-010).
12
+ //
13
+ // A2A 1.0 reserves -32001..-32009; JSON-RPC 2.0 leaves -32000..-32099 to the
14
+ // implementation. These three sit above A2A's reserved block, with room for it
15
+ // to grow, and are the "JSON-RPC custom error" A2A §13.2 names as the example
16
+ // for this binding.
17
+ //
18
+ // apcore distinguishes these three refusals from each other and from every
19
+ // other failure. Collapsing them onto -32001 (which means "unknown or non-owned
20
+ // task id") or -32603 (which every agent reads as "retry me") told the caller a
21
+ // *different* failure had happened, one whose correct response is the opposite
22
+ // of the real one.
23
+ export const CODE_ACCESS_DENIED = -32040;
24
+ export const CODE_APPROVAL_DENIED = -32041;
25
+ export const CODE_APPROVAL_TIMEOUT = -32042;
26
+ /**
27
+ * The three governance refusal codes, each with its JSON-RPC code and the fixed
28
+ * message it reports by default.
29
+ *
30
+ * `APPROVAL_PENDING` is deliberately absent: it is a resumable pause carrying
31
+ * the `approvalId` the caller resumes with, handled by the executor before it
32
+ * ever reaches the mapper (srs FR-EXE-002). Sweeping it in here would turn that
33
+ * pause into a terminal failure.
34
+ */
35
+ const GOVERNANCE_REFUSALS = new Map([
36
+ [ErrorCodes.ACL_DENIED, { code: CODE_ACCESS_DENIED, message: "Access denied" }],
37
+ [ErrorCodes.APPROVAL_DENIED, { code: CODE_APPROVAL_DENIED, message: "Approval denied" }],
38
+ [ErrorCodes.APPROVAL_TIMEOUT, { code: CODE_APPROVAL_TIMEOUT, message: "Approval timed out" }],
39
+ ]);
40
+ /** Whether an apcore error code is one of the three governance refusals. */
41
+ export function isGovernanceRefusal(code) {
42
+ return code !== undefined && GOVERNANCE_REFUSALS.has(code);
43
+ }
6
44
  export class ErrorMapper {
45
+ discloseRefusalReason;
46
+ /**
47
+ * @param discloseRefusalReason Forward apcore's own message for the three
48
+ * governance refusal codes instead of the fixed per-class string
49
+ * (srs FR-ERR-011). Off by default. The code never changes with the flag —
50
+ * what a refusal *is* does not depend on how much a deployment chooses to
51
+ * say about it.
52
+ */
53
+ constructor(discloseRefusalReason = false) {
54
+ this.discloseRefusalReason = discloseRefusalReason;
55
+ }
7
56
  /** ErrorFormatter interface for apcore ErrorFormatterRegistry. */
8
57
  format(error, _context) {
9
58
  const rpcError = this.toJsonRpcError(error);
@@ -25,6 +74,21 @@ export class ErrorMapper {
25
74
  }
26
75
  return { code: CODE_INTERNAL_ERROR, message: "Internal server error" };
27
76
  }
77
+ /**
78
+ * Caller-facing message for a governance refusal.
79
+ *
80
+ * Default: the fixed per-class string. With `discloseRefusalReason`
81
+ * (srs FR-ERR-011): apcore's own message, through the same sanitizer every
82
+ * other forwarded message goes through. An empty or whitespace-only apcore
83
+ * message falls back to the fixed string rather than sending the caller
84
+ * nothing.
85
+ */
86
+ refusalMessage(fixed, error) {
87
+ if (!this.discloseRefusalReason)
88
+ return fixed;
89
+ const disclosed = this.sanitizeMessage(String(error.message ?? ""));
90
+ return disclosed.trim() ? disclosed : fixed;
91
+ }
28
92
  handleApcoreError(error, errorCode) {
29
93
  if (errorCode === ErrorCodes.MODULE_NOT_FOUND) {
30
94
  const message = this.sanitizeMessage(error.message);
@@ -43,8 +107,15 @@ export class ErrorMapper {
43
107
  const description = this.sanitizeMessage(error.message);
44
108
  return { code: CODE_INVALID_PARAMS, message: `Invalid input: ${description}` };
45
109
  }
46
- if (errorCode === ErrorCodes.ACL_DENIED) {
47
- return { code: CODE_TASK_NOT_FOUND, message: "Task not found" };
110
+ // The A2A spec §13.2 MUST NOT forbids revealing *the existence of a
111
+ // resource*, not the *class* of failure. A fixed "Access denied" /
112
+ // "Approval denied" / "Approval timed out" names no caller, target,
113
+ // approver or rule, so it discloses nothing — a caller that named a skill
114
+ // already held that id — while still telling an agent to stop rather than
115
+ // retry.
116
+ const refusal = GOVERNANCE_REFUSALS.get(errorCode);
117
+ if (refusal !== undefined) {
118
+ return { code: refusal.code, message: this.refusalMessage(refusal.message, error) };
48
119
  }
49
120
  if (errorCode === ErrorCodes.MODULE_TIMEOUT) {
50
121
  return { code: CODE_INTERNAL_ERROR, message: "Execution timeout" };
@@ -119,13 +190,18 @@ export function isServerSideSchemaError(message) {
119
190
  * {@link sanitizeMessage} does not strip (module ids, versions, env-var names,
120
191
  * hostnames). `userFixable` is also settable per-error by the module author,
121
192
  * which would let any module widen any fixed per-class string at will,
122
- * including the `ACL_DENIED` mask.
193
+ * including the governance refusals.
194
+ *
195
+ * The three governance codes (`ACL_DENIED`, `APPROVAL_DENIED`,
196
+ * `APPROVAL_TIMEOUT`) are in this partition only when `discloseRefusalReason` is
197
+ * set — the same flag the mapper branches on, so the two surfaces agree under
198
+ * either setting.
123
199
  *
124
200
  * `errorMapper message policy matches toJsonRpcError` locks this to the
125
- * branching in `ErrorMapper.handleApcoreError` across every apcore error code,
126
- * so the two cannot drift.
201
+ * branching in `ErrorMapper.handleApcoreError` across every apcore error code
202
+ * and both flag values, so the two cannot drift.
127
203
  */
128
- export function carriesCallerDetail(error) {
204
+ export function carriesCallerDetail(error, discloseRefusalReason = false) {
129
205
  const code = error?.code;
130
206
  if (code === ErrorCodes.MODULE_NOT_FOUND || code === ErrorCodes.GENERAL_INVALID_INPUT) {
131
207
  return true;
@@ -133,6 +209,12 @@ export function carriesCallerDetail(error) {
133
209
  if (code === ErrorCodes.SCHEMA_VALIDATION_ERROR) {
134
210
  return !isServerSideSchemaError(String(error.message ?? ""));
135
211
  }
212
+ // The three governance codes move into and out of this partition with the
213
+ // flag, so the task-status surface forwards exactly what the JSON-RPC surface
214
+ // does under either setting (srs FR-ERR-011 criterion 4).
215
+ if (isGovernanceRefusal(code)) {
216
+ return discloseRefusalReason;
217
+ }
136
218
  return false;
137
219
  }
138
220
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/adapters/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,MAAM,qBAAqB,GAAG,CAAC,KAAK,CAAC;AACrC,MAAM,mBAAmB,GAAG,CAAC,KAAK,CAAC;AACnC,MAAM,mBAAmB,GAAG,CAAC,KAAK,CAAC;AACnC,MAAM,mBAAmB,GAAG,CAAC,KAAK,CAAC;AAOnC,MAAM,OAAO,WAAW;IACtB,kEAAkE;IAClE,MAAM,CAAC,KAAc,EAAE,QAAkB;QACvC,MAAM,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;QAC5C,OAAO,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,CAAC,OAAO,EAAE,CAAC;IAC5D,CAAC;IAED,cAAc,CAAC,KAAc;QAC3B,0EAA0E;QAC1E,0EAA0E;QAC1E,mBAAmB;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AAO,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;IAChD,qDAAqD;IACrD,SAAS,GAAG,SAAS,CAAC,OAAO,CAAC,uCAAuC,EAAE,EAAE,CAAC,CAAC;IAC3E,OAAO,SAAS,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AAC7D,CAAC"}
@@ -15,6 +15,33 @@ export interface ModuleDescriptor {
15
15
  annotations?: Record<string, unknown>;
16
16
  metadata?: Record<string, unknown>;
17
17
  }
18
+ /**
19
+ * Append apcore's behavioral annotations to a skill's tags (srs FR-SKL-004).
20
+ *
21
+ * A2A 1.0 `AgentSkill` is `{id, name, description, tags, examples, inputModes,
22
+ * outputModes, securityRequirements}` — no `extensions`, no `metadata` — so
23
+ * `tags` is the only carrier that exists. The `apcore:` prefix keeps these out
24
+ * of the module's own flat tag namespace, where a user tag named `destructive`
25
+ * would otherwise be indistinguishable from the annotation.
26
+ *
27
+ * Without this the Agent Card carried enough for a caller to *construct* a call
28
+ * and not enough to judge whether making it is safe. It is also what makes retry
29
+ * semantics usable: `retryable` is a property of the error, but whether a retry
30
+ * is safe is a property of the operation, and a timeout is retryable for a read
31
+ * and dangerous for a non-idempotent mutation.
32
+ *
33
+ * Only truthy flags are emitted, matching how the apcore MCP binding maps the
34
+ * same annotations onto optional `readOnlyHint` / `destructiveHint` /
35
+ * `idempotentHint`. Absence means "not asserted", never "asserted false".
36
+ */
37
+ export declare function appendAnnotationTags(tags: string[], descriptor: ModuleDescriptor): void;
38
+ /**
39
+ * Whether a module is gated behind human approval.
40
+ *
41
+ * Used by the Agent Card builder to withhold the skill from the public card
42
+ * (srs FR-AGC-003) and restore it on the extended one (srs FR-AGC-004).
43
+ */
44
+ export declare function requiresApproval(descriptor: ModuleDescriptor | null | undefined): boolean;
18
45
  export declare class SkillMapper {
19
46
  private schemaConverter;
20
47
  constructor(schemaConver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AE,MAAM,GAAG,UAAU,GAAG,IAAI;IA4C3E,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IAO1C,OAAO,CAAC,iBAAiB;IASzB,OAAO,CAAC,kBAAkB;IAM1B,aAAa,CAAC,UAAU,EAAE,gBAAgB,GAAG,MAAM,EAAE;CAQtD"}
@@ -1,4 +1,64 @@
1
1
  import { SchemaConverter } from "./schema.js";
2
+ /**
3
+ * The four behavioral annotations promoted onto the A2A wire, with the tag each
4
+ * becomes. Order is fixed so the card is byte-identical across the three
5
+ * bindings (srs FR-SKL-004 criterion 8).
6
+ */
7
+ const ANNOTATION_TAGS = [
8
+ ["readonly", "apcore:readonly"],
9
+ ["destructive", "apcore:destructive"],
10
+ ["idempotent", "apcore:idempotent"],
11
+ ["requires_approval", "apcore:requires-approval"],
12
+ ];
13
+ /** camelCase aliases, since a descriptor may arrive from either convention. */
14
+ const ANNOTATION_ALIASES = {
15
+ requires_approval: "requiresApproval",
16
+ };
17
+ function annotationFlag(annotations, field) {
18
+ const alias = ANNOTATION_ALIASES[field];
19
+ return Boolean(annotations[field] ?? (alias !== undefined ? annotations[alias] : undefined));
20
+ }
21
+ /**
22
+ * Append apcore's behavioral annotations to a skill's tags (srs FR-SKL-004).
23
+ *
24
+ * A2A 1.0 `AgentSkill` is `{id, name, description, tags, examples, inputModes,
25
+ * outputModes, securityRequirements}` — no `extensions`, no `metadata` — so
26
+ * `tags` is the only carrier that exists. The `apcore:` prefix keeps these out
27
+ * of the module's own flat tag namespace, where a user tag named `destructive`
28
+ * would otherwise be indistinguishable from the annotation.
29
+ *
30
+ * Without this the Agent Card carried enough for a caller to *construct* a call
31
+ * and not enough to judge whether making it is safe. It is also what makes retry
32
+ * semantics usable: `retryable` is a property of the error, but whether a retry
33
+ * is safe is a property of the operation, and a timeout is retryable for a read
34
+ * and dangerous for a non-idempotent mutation.
35
+ *
36
+ * Only truthy flags are emitted, matching how the apcore MCP binding maps the
37
+ * same annotations onto optional `readOnlyHint` / `destructiveHint` /
38
+ * `idempotentHint`. Absence means "not asserted", never "asserted false".
39
+ */
40
+ export function appendAnnotationTags(tags, descriptor) {
41
+ const annotations = descriptor.annotations;
42
+ if (!annotations)
43
+ return;
44
+ for (const [field, tag] of ANNOTATION_TAGS) {
45
+ if (annotationFlag(annotations, field) && !tags.includes(tag)) {
46
+ tags.push(tag);
47
+ }
48
+ }
49
+ }
50
+ /**
51
+ * Whether a module is gated behind human approval.
52
+ *
53
+ * Used by the Agent Card builder to withhold the skill from the public card
54
+ * (srs FR-AGC-003) and restore it on the extended one (srs FR-AGC-004).
55
+ */
56
+ export function requiresApproval(descriptor) {
57
+ const annotations = descriptor?.annotations;
58
+ if (!annotations)
59
+ return false;
60
+ return annotationFlag(annotations, "requires_approval");
61
+ }
2
62
  export class SkillMapper {
3
63
  schemaConverter;
4
64
  // Share root-type detection with SchemaConverter so the "string root" rule
@@ -29,6 +89,7 @@ export class SkillMapper {
29
89
  const resolvedTags = display.tags?.length
30
90
  ? [...display.tags]
31
91
  : [...(descriptor.tags ?? [])];
92
+ appendAnnotationTags(resolvedTags, descriptor);
32
93
  return {
33
94
  id,
34
95
  name: skillName,
@@ -1 +1 @@
1
- {"version":3,"file":"skill-mapper.js","sourceRoot":"","sources":["../../src/adapters/skill-mapper.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAmB,MAAM,aAAa,CAAC;AAgB/D,MAAM,OAAO,WAAW;IAGF;IAFpB,2EAA2E;IAC3E,8BAA8B;IAC9B,YAAoB,kBAAmC,IAAI,eAAe,EAAE;QAAxD,oBAAe,GAAf,eAAe,CAAyC;IAAG,CAAC;IAEhF,OAAO,CAAC,UAA4B,EAAE,QAAiB;QACrD,MAAM,WAAW,GAAG,UAAU,CAAC,WAAW,CAAC;QAC3C,IAAI,CAAC,WAAW;YAAE,OAAO,IAAI,CAAC;QAE9B,MAAM,EAAE,GAAG,UAAU,CAAC,SAAS,IAAI,UAAU,CAAC,QAAQ,IAAI,QAAQ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AQ,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC;YACvC,IAAI,EAAE,CAAC,KAAK;gBAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;QAC9C,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
package/dist/cli.d.ts CHANGED
@@ -1,4 +1,67 @@
1
1
  #!/usr/bin/env node
2
+ import { parseArgs } from "node:util";
3
+ /**
4
+ * The `values` half of a `parseArgs` result under `strict: false`.
5
+ *
6
+ * Wider than the flag table suggests on purpose: with `strict: false` node
7
+ * accepts `--metrics=x` for a boolean and repeats for a non-`multiple` option,
8
+ * so every entry may arrive as a string, a boolean, or an array of either.
9
+ */
10
+ type CliValues = Record<string, string | boolean | (string | boolean)[] | undefined>;
11
+ /**
12
+ * Exit `2` — a usage error. The command line itself is wrong.
13
+ *
14
+ * Distinguished from {@link fail} because retrying an exit-2 command unchanged
15
+ * will always fail, while an exit-1 command may succeed once the directory,
16
+ * config or network it named is fixed. That is a difference a supervisor or CI
17
+ * job can act on, and this SDK previously collapsed both onto `1` — losing a
18
+ * distinction Python's argparse and Rust's clap each provide for free.
19
+ *
20
+ * `2` rather than some other number because it is what argparse, clap and GNU
21
+ * getopt all use for a usage fault, so the three bindings agree with each other
22
+ * and with the tools around them.
23
+ */
24
+ export declare function failUsage(message: string): never;
2
25
  export declare function resolveAuthKey(authKey?: string): string | undefined;
26
+ /**
27
+ * Parse `serve`'s argv.
28
+ *
29
+ * Split out of {@link main} so the flag surface is reachable without starting a
30
+ * server: the `--openapi-no-deprecated` contract is half in this table (no
31
+ * `default`) and half in {@link mergeOpenapiSettings} (the presence check), and
32
+ * either half alone silently reverses a config `include_deprecated: false`.
33
+ */
34
+ export declare function parseCliArgs(args?: string[]): ReturnType<typeof parseArgs>;
3
35
  export declare function main(): Promise<void>;
36
+ /**
37
+ * Parse repeated `--openapi-header "Key: Value"` flags into a header map.
38
+ *
39
+ * These authenticate the **spec fetch only**. They are deliberately not reused
40
+ * for proxied calls: a document is often public while the API behind it is not,
41
+ * and broadcasting a spec-read key on every skill invocation would be a
42
+ * privilege escalation the operator never wrote down.
43
+ */
44
+ export declare function parseOpenapiHeaders(raw: string[] | undefined): Record<string, string> | undefined;
45
+ /**
46
+ * Resolve the OpenAPI backend settings: CLI flags over the Config Bus.
47
+ *
48
+ * Implements the precedence the feature spec states — **an explicit CLI flag
49
+ * beats the `apcore-a2a.openapi` Config Bus section, which beats the default** —
50
+ * and implements it PER KEY, not per source. Choosing the whole source by
51
+ * whoever named `spec` would make a `--openapi-prefix` alongside a
52
+ * config-declared `spec` a silent no-op: the same shape as the apcore-mcp
53
+ * `--openapi-header` defect this project filed upstream (apcore-mcp-rust#8).
54
+ *
55
+ * The returned mapping is in the Config Bus's own snake_case, so it can be
56
+ * handed straight to `buildOpenapiBackendFromConfig` — which is also what makes
57
+ * `timeout`, `include`, `exclude` and `acknowledge_unapproved_writes` reachable
58
+ * from a running server: none of them has a CLI flag, and before this the
59
+ * section had no reader anywhere in `src/`.
60
+ *
61
+ * Returns `null` when neither route yields a `spec`, which is the ordinary "no
62
+ * OpenAPI configured" outcome rather than an error. A section that is not a
63
+ * mapping is returned UNCHANGED — see below.
64
+ */
65
+ export declare function mergeOpenapiSettings(values: CliValues): Promise<unknown>;
66
+ export {};
4
67
  //# sourceMappingURL=cli.d.ts.map
package/dist/cli.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AA4CA,wBAAgB,cAAc,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAYnE;AAED,wBAAsB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAsD1C"}
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAKA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAqDtC;;;;;;GAMG;AACH,KAAK,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,CAAC,MAAM,GAAG,OAAO,CAAC,EAAE,GAAG,SAAS,CAAC,CAAC;AAarF;;;;;;;;;;;;GAYG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,KAAK,CAEhD;AAED,wBAAgB,cAAc,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAYnE;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,OAAO,SAAS,CAAC,CA6C1E;AAwDD,wBAAsB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CA+B1C;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,MAAM,EAAE,GAAG,SAAS,GACxB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAmBpC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,oBAAoB,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,CAuC9E"}