@andpipes/cli 0.1.4 → 0.1.5

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/dist/index.cjs CHANGED
@@ -619,6 +619,26 @@ var ConfirmationRequiredError = class extends Error {
619
619
  }
620
620
  };
621
621
 
622
+ // src/lib/publication-review-profile.ts
623
+ var CLI_PUBLICATION_REVIEW_PROFILE = 2;
624
+ var PUBLICATION_ERROR_REASON_CODES = Object.freeze({
625
+ publication_plan_stale: "AP_CONFLICT",
626
+ publication_review_profile_invalid: "AP_INPUT_INVALID",
627
+ publication_schema_review_too_large: "AP_INPUT_INVALID",
628
+ schema_review_receipt_mismatch: "AP_CONFLICT"
629
+ });
630
+ function isPublicationErrorReasonFor(code, reason) {
631
+ return typeof reason === "string" && Object.hasOwn(PUBLICATION_ERROR_REASON_CODES, reason) && PUBLICATION_ERROR_REASON_CODES[reason] === code;
632
+ }
633
+ function parsePublicationErrorReason(status, code, details) {
634
+ if (status < 400 || status > 499) return void 0;
635
+ if (details === null || typeof details !== "object" || Array.isArray(details)) return void 0;
636
+ const record = details;
637
+ const keys = Object.keys(record);
638
+ if (keys.length !== 1 || keys[0] !== "reason") return void 0;
639
+ return isPublicationErrorReasonFor(code, record.reason) ? record.reason : void 0;
640
+ }
641
+
622
642
  // src/lib/backend.ts
623
643
  var ADMIN_API_ORIGIN = "https://api.andpipe.com";
624
644
  var ADMIN_API_TIMEOUT_MS = 1e4;
@@ -648,6 +668,7 @@ var AdminApiClientError = class extends Error {
648
668
  detailsAbsent;
649
669
  scopeRegistrationReason;
650
670
  publishGateToolNames;
671
+ publicationReason;
651
672
  constructor(code, message, status, confirmationRequired, openApiAuthModeMismatch, safeDetails = {}) {
652
673
  super(message);
653
674
  this.name = "AdminApiClientError";
@@ -658,6 +679,7 @@ var AdminApiClientError = class extends Error {
658
679
  this.detailsAbsent = safeDetails.detailsAbsent === true;
659
680
  this.scopeRegistrationReason = safeDetails.scopeRegistrationReason;
660
681
  this.publishGateToolNames = safeDetails.publishGateToolNames === void 0 ? void 0 : Object.freeze([...safeDetails.publishGateToolNames]);
682
+ this.publicationReason = safeDetails.publicationReason;
661
683
  }
662
684
  };
663
685
  function clientError(code, message, status) {
@@ -872,7 +894,8 @@ function withKnownResponseStatus(error, responseStatus) {
872
894
  {
873
895
  detailsAbsent: error.detailsAbsent,
874
896
  ...error.scopeRegistrationReason === void 0 ? {} : { scopeRegistrationReason: error.scopeRegistrationReason },
875
- ...error.publishGateToolNames === void 0 ? {} : { publishGateToolNames: error.publishGateToolNames }
897
+ ...error.publishGateToolNames === void 0 ? {} : { publishGateToolNames: error.publishGateToolNames },
898
+ ...error.publicationReason === void 0 ? {} : { publicationReason: error.publicationReason }
876
899
  }
877
900
  );
878
901
  }
@@ -941,6 +964,7 @@ function safeApiError(status, value) {
941
964
  const code = typeof candidate === "string" && SAFE_AP_CODE_RE.test(candidate) ? candidate : "AP_HTTP_ERROR";
942
965
  const confirmationRequired = code === "AP_CONFIRMATION_REQUIRED" && status === 409 ? parsePublicationConfirmationRequiredDetails(errorRecord?.details) : void 0;
943
966
  const openApiAuthModeMismatch = code === "AP_CONFLICT" && status === 409 ? parseOpenApiImportAuthModeMismatch(errorRecord?.details) : void 0;
967
+ const publicationReason = parsePublicationErrorReason(status, code, errorRecord?.details);
944
968
  return new AdminApiClientError(
945
969
  code,
946
970
  `Admin API request failed (${code}; HTTP ${status})`,
@@ -950,7 +974,8 @@ function safeApiError(status, value) {
950
974
  {
951
975
  // AP error envelopeを受け取れた場合だけ「detailsなし」を判定できる。
952
976
  detailsAbsent: errorRecord !== void 0 && (errorRecord.details === null || errorRecord.details === void 0),
953
- ...parseScopeRegistrationErrorDetails(status, errorRecord?.details)
977
+ ...parseScopeRegistrationErrorDetails(status, errorRecord?.details),
978
+ ...publicationReason === void 0 ? {} : { publicationReason }
954
979
  }
955
980
  );
956
981
  }
@@ -1084,6 +1109,13 @@ function publicationPlanBody(input) {
1084
1109
  ...input.templateProvenance === void 0 ? {} : { templateProvenance: input.templateProvenance }
1085
1110
  };
1086
1111
  }
1112
+ function publicationReviewProfileOption(options) {
1113
+ if (options === void 0) return void 0;
1114
+ if (options === null || typeof options !== "object" || Object.keys(options).join(",") !== "reviewProfile" || options.reviewProfile !== 2) {
1115
+ throw clientError("AP_INPUT_INVALID", "tool publication review profile option is invalid");
1116
+ }
1117
+ return options.reviewProfile;
1118
+ }
1087
1119
  function publicationApplyBody(input) {
1088
1120
  const common = publicationPlanBody(input);
1089
1121
  if (!import_tool_contract.PUBLICATION_SHA256_COMMITMENT_RE.test(input.planCommitment)) {
@@ -1439,6 +1471,10 @@ var AdminApiClient = class {
1439
1471
  this.#sleep = options.sleep ?? ((milliseconds) => new Promise((resolve7) => setTimeout(resolve7, milliseconds)));
1440
1472
  }
1441
1473
  async #request(path, options = {}) {
1474
+ return (await this.#requestWithHeaders(path, options)).value;
1475
+ }
1476
+ /** 2xx bodyと、そのresponse headerを返す。headerはcommand層が必要な値だけを読む。 */
1477
+ async #requestWithHeaders(path, options = {}) {
1442
1478
  const url = buildUrl(path);
1443
1479
  const method = options.method ?? "GET";
1444
1480
  const attempts = method === "GET" ? ADMIN_API_MAX_GET_ATTEMPTS : 1;
@@ -1460,6 +1496,9 @@ var AdminApiClient = class {
1460
1496
  if (options.authenticated !== false) headers.set("Authorization", `Bearer ${this.#token}`);
1461
1497
  if (body !== void 0) headers.set("Content-Type", "application/json");
1462
1498
  if (options.idempotencyKey) headers.set("Idempotency-Key", options.idempotencyKey);
1499
+ if (options.reviewProfile !== void 0) {
1500
+ headers.set(import_tool_contract.PUBLICATION_REVIEW_PROFILE_HEADER, String(options.reviewProfile));
1501
+ }
1463
1502
  response = await this.#fetch(url, {
1464
1503
  method,
1465
1504
  headers,
@@ -1516,8 +1555,8 @@ var AdminApiClient = class {
1516
1555
  }
1517
1556
  throw safeApiError(response.status, errorBody);
1518
1557
  }
1519
- if (options.responseType === "text") return text;
1520
- return parseJson(text);
1558
+ if (options.responseType === "text") return { value: text, headers: response.headers };
1559
+ return { value: parseJson(text), headers: response.headers };
1521
1560
  }
1522
1561
  throw clientError("AP_NETWORK_ERROR", "Admin API request failed");
1523
1562
  }
@@ -1663,24 +1702,41 @@ var AdminApiClient = class {
1663
1702
  status: connector.status
1664
1703
  };
1665
1704
  }
1666
- async planPublication(projectId, body) {
1667
- return this.#request(`/v1/projects/${assertProjectId(projectId)}/tool-publications:plan`, {
1668
- method: "POST",
1669
- body: publicationPlanBody(body),
1670
- maxRequestBytes: ADMIN_API_PUBLICATION_REQUEST_MAX_BYTES,
1671
- maxResponseBytes: ADMIN_API_PUBLICATION_RESPONSE_MAX_BYTES
1672
- });
1705
+ async planPublication(projectId, body, options) {
1706
+ const reviewProfile = publicationReviewProfileOption(options);
1707
+ const response = await this.#requestWithHeaders(
1708
+ `/v1/projects/${assertProjectId(projectId)}/tool-publications:plan`,
1709
+ {
1710
+ method: "POST",
1711
+ body: publicationPlanBody(body),
1712
+ maxRequestBytes: ADMIN_API_PUBLICATION_REQUEST_MAX_BYTES,
1713
+ maxResponseBytes: ADMIN_API_PUBLICATION_RESPONSE_MAX_BYTES,
1714
+ ...reviewProfile === void 0 ? {} : { reviewProfile }
1715
+ }
1716
+ );
1717
+ if (reviewProfile === void 0) return response.value;
1718
+ const planResponse = {
1719
+ body: response.value,
1720
+ reviewProfileHeader: response.headers.get(import_tool_contract.PUBLICATION_REVIEW_PROFILE_HEADER)
1721
+ };
1722
+ return planResponse;
1673
1723
  }
1674
- async applyPublication(projectId, idempotencyKey, body) {
1724
+ /**
1725
+ * 初回apply(confirmation=null)と承認済みapply。options付き (#730) だけreview profile headerを送る。
1726
+ * request bodyとIdempotency-Keyはheaderの有無で変えない。
1727
+ */
1728
+ async applyPublication(projectId, idempotencyKey, body, options) {
1675
1729
  if (!/^[A-Za-z0-9._:-]{22,200}$/u.test(idempotencyKey)) {
1676
1730
  throw clientError("AP_INPUT_INVALID", "tool publication Idempotency-Key is invalid");
1677
1731
  }
1732
+ const reviewProfile = publicationReviewProfileOption(options);
1678
1733
  return this.#request(`/v1/projects/${assertProjectId(projectId)}/tool-publications`, {
1679
1734
  method: "POST",
1680
1735
  body: publicationApplyBody(body),
1681
1736
  idempotencyKey,
1682
1737
  maxRequestBytes: ADMIN_API_PUBLICATION_REQUEST_MAX_BYTES,
1683
- maxResponseBytes: ADMIN_API_PUBLICATION_RESPONSE_MAX_BYTES
1738
+ maxResponseBytes: ADMIN_API_PUBLICATION_RESPONSE_MAX_BYTES,
1739
+ ...reviewProfile === void 0 ? {} : { reviewProfile }
1684
1740
  });
1685
1741
  }
1686
1742
  async planOpenApiImport(projectId, input) {
@@ -8514,6 +8570,10 @@ var PUBLICATION_RESPONSE_MAX_BYTES = 96 * 1024;
8514
8570
  var INITIAL_APPLY_MAX_ATTEMPTS = 3;
8515
8571
  var DEFAULT_PUBLISH_MESSAGES = import_localization9.CLI_MESSAGES.ja.publish;
8516
8572
  var DEFAULT_SCOPE_REGISTRATION_MESSAGES2 = import_localization9.OAUTH_SCOPE_REGISTRATION_MESSAGES.ja.cli;
8573
+ var DEFAULT_SCHEMA_REVIEW_MESSAGES = import_localization9.PUBLICATION_SCHEMA_REVIEW_CLI_MESSAGES.ja;
8574
+ var REVIEW_PROFILE_REQUEST = Object.freeze({
8575
+ reviewProfile: CLI_PUBLICATION_REVIEW_PROFILE
8576
+ });
8517
8577
  var PLAN_KEYS = [
8518
8578
  "requestId",
8519
8579
  "environment",
@@ -8673,10 +8733,41 @@ function parseWarnings(value, messages) {
8673
8733
  throw responseInvalid("publication_warnings_invalid", messages);
8674
8734
  }
8675
8735
  }
8676
- function parsePlan(value, connectorId, candidateCommitment, expectedToolNames, messages) {
8736
+ function schemaReviewFailure(code, reason, text, status) {
8737
+ return new PublishCommandError(code, reason, `${text} (${reason})`, status);
8738
+ }
8739
+ function negotiateReviewProfile(response, messages, schemaReviewMessages) {
8740
+ const envelope = asRecord4(response);
8741
+ if (!envelope || !hasExactKeys3(envelope, ["body", "reviewProfileHeader"]) || envelope.reviewProfileHeader !== null && typeof envelope.reviewProfileHeader !== "string") {
8742
+ throw responseInvalid("publication_plan_invalid", messages);
8743
+ }
8744
+ const header = envelope.reviewProfileHeader;
8745
+ if (header !== null && header !== "1" && header !== "2") {
8746
+ throw schemaReviewFailure(
8747
+ "AP_RESPONSE_INVALID",
8748
+ "publication_review_profile_header_invalid",
8749
+ schemaReviewMessages.reviewProfileHeaderInvalid
8750
+ );
8751
+ }
8752
+ const body = asRecord4(envelope.body);
8753
+ const bodyDeclaresProfile = body !== null && Object.hasOwn(body, "reviewProfile");
8754
+ const profile = header === "2" ? 2 : 1;
8755
+ if (profile === 2 ? !bodyDeclaresProfile || body?.reviewProfile !== 2 : bodyDeclaresProfile) {
8756
+ throw schemaReviewFailure(
8757
+ "AP_CONFLICT",
8758
+ "publication_review_profile_mismatch",
8759
+ schemaReviewMessages.reviewProfileMismatch
8760
+ );
8761
+ }
8762
+ return {
8763
+ session: header === null ? { kind: "legacy", profile: 1 } : { kind: "negotiated", profile },
8764
+ body: envelope.body
8765
+ };
8766
+ }
8767
+ function parsePlan(value, connectorId, candidateCommitment, expectedToolNames, profile, messages) {
8677
8768
  assertCanonicalResponseSize(value, "publication_plan_too_large", messages);
8678
8769
  const plan = asRecord4(value);
8679
- if (!plan || !hasExactKeys3(plan, PLAN_KEYS) || !isCanonicalUuid(plan.requestId) || plan.environment !== "production" || plan.connectorId !== connectorId || !isCanonicalTimestamp(plan.connectorRevision) || !isCommitment(plan.connectorCommitment) || !isCommitment(plan.policyCommitment) || plan.candidateCommitment !== candidateCommitment || !isCommitment(plan.candidateCommitment) || !isCommitment(plan.baseCommitment) || !isCommitment(plan.planCommitment) || !Array.isArray(plan.tools) || typeof plan.applyAllowed !== "boolean" || !Array.isArray(plan.blockedReasons) || !plan.blockedReasons.every(
8770
+ if (!plan || !hasExactKeys3(plan, profile === 2 ? [...PLAN_KEYS, "reviewProfile"] : PLAN_KEYS) || profile === 2 && plan.reviewProfile !== 2 || !isCanonicalUuid(plan.requestId) || plan.environment !== "production" || plan.connectorId !== connectorId || !isCanonicalTimestamp(plan.connectorRevision) || !isCommitment(plan.connectorCommitment) || !isCommitment(plan.policyCommitment) || plan.candidateCommitment !== candidateCommitment || !isCommitment(plan.candidateCommitment) || !isCommitment(plan.baseCommitment) || !isCommitment(plan.planCommitment) || !Array.isArray(plan.tools) || typeof plan.applyAllowed !== "boolean" || !Array.isArray(plan.blockedReasons) || !plan.blockedReasons.every(
8680
8771
  (reason) => typeof reason === "string" && BLOCKED_REASONS.has(reason)
8681
8772
  ) || !isStrictlySorted(plan.blockedReasons) || plan.applyAllowed !== (plan.blockedReasons.length === 0)) {
8682
8773
  throw responseInvalid("publication_plan_invalid", messages);
@@ -8685,6 +8776,7 @@ function parsePlan(value, connectorId, candidateCommitment, expectedToolNames, m
8685
8776
  let safeDiff;
8686
8777
  try {
8687
8778
  safeDiff = (0, import_tool_contract9.parsePublicationSafeDiffDto)({
8779
+ ...profile === 2 ? { reviewProfile: 2 } : {},
8688
8780
  tools: plan.tools,
8689
8781
  retainedTools: plan.retainedTools,
8690
8782
  warnings: plan.warnings
@@ -8692,13 +8784,16 @@ function parsePlan(value, connectorId, candidateCommitment, expectedToolNames, m
8692
8784
  } catch {
8693
8785
  throw responseInvalid("publication_safe_diff_invalid", messages);
8694
8786
  }
8787
+ if (safeDiff.reviewProfile === 2 !== (profile === 2)) {
8788
+ throw responseInvalid("publication_safe_diff_invalid", messages);
8789
+ }
8695
8790
  const tools = safeDiff.tools;
8696
8791
  const toolNames = tools.map((tool) => tool.toolName);
8697
8792
  if (!isStrictlySorted(toolNames) || JSON.stringify(toolNames) !== JSON.stringify(expectedToolNames)) {
8698
8793
  throw responseInvalid("publication_plan_tools_order_invalid", messages);
8699
8794
  }
8700
8795
  const warnings = safeDiff.warnings;
8701
- const expectedPlanCommitment = (0, import_tool_contract9.publicationCommitment)("plan", {
8796
+ const expectedPlanCommitment = (0, import_tool_contract9.publicationCommitment)(profile === 2 ? "planV2" : "plan", {
8702
8797
  candidateCommitment,
8703
8798
  baseCommitment: plan.baseCommitment,
8704
8799
  connectorId,
@@ -8726,6 +8821,7 @@ function parsePlan(value, connectorId, candidateCommitment, expectedToolNames, m
8726
8821
  throw responseInvalid("publication_plan_gate_inconsistent", messages);
8727
8822
  }
8728
8823
  return {
8824
+ ...profile === 2 ? { reviewProfile: 2 } : {},
8729
8825
  requestId: plan.requestId,
8730
8826
  environment: "production",
8731
8827
  connectorId,
@@ -8853,8 +8949,36 @@ function typedStatus2(error) {
8853
8949
  const status = error.status;
8854
8950
  return typeof status === "number" && Number.isInteger(status) && status >= 100 && status <= 599 ? status : void 0;
8855
8951
  }
8856
- function remoteError(error, phase, messages) {
8952
+ function typedPublicationReason(error, code) {
8953
+ if (error === null || typeof error !== "object") return void 0;
8954
+ const status = typedStatus2(error);
8955
+ if (status === void 0 || status < 400 || status > 499) return void 0;
8956
+ const reason = error.publicationReason;
8957
+ return isPublicationErrorReasonFor(code, reason) ? reason : void 0;
8958
+ }
8959
+ function publicationReasonText(reason, schemaReviewMessages) {
8960
+ switch (reason) {
8961
+ case "publication_schema_review_too_large":
8962
+ return schemaReviewMessages.schemaReviewTooLarge;
8963
+ case "publication_review_profile_invalid":
8964
+ return schemaReviewMessages.reviewProfileInvalid;
8965
+ case "schema_review_receipt_mismatch":
8966
+ return schemaReviewMessages.receiptMismatch;
8967
+ case "publication_plan_stale":
8968
+ return schemaReviewMessages.planStale;
8969
+ }
8970
+ }
8971
+ function remoteError(error, phase, messages, schemaReviewMessages) {
8857
8972
  const code = typedCode2(error) ?? "AP_NETWORK_ERROR";
8973
+ const publicationReason = schemaReviewMessages === void 0 ? void 0 : typedPublicationReason(error, code);
8974
+ if (publicationReason !== void 0 && schemaReviewMessages !== void 0) {
8975
+ return schemaReviewFailure(
8976
+ code,
8977
+ publicationReason,
8978
+ publicationReasonText(publicationReason, schemaReviewMessages),
8979
+ typedStatus2(error)
8980
+ );
8981
+ }
8858
8982
  return new PublishCommandError(
8859
8983
  code,
8860
8984
  `${phase}_failed`,
@@ -8916,6 +9040,42 @@ function writeSafeJson(writer, value) {
8916
9040
  function writePlan(writer, plan) {
8917
9041
  writeSafeJson(writer, { phase: "plan", ...plan });
8918
9042
  }
9043
+ function writeSchemaReviewSummary(writer, plan, schemaReviewMessages) {
9044
+ if (plan.reviewProfile !== 2) return;
9045
+ const reviewed = plan.tools.filter((tool) => (tool.schemaReview?.enums.length ?? 0) > 0);
9046
+ if (reviewed.length === 0) return;
9047
+ interactive(writer, schemaReviewMessages.heading);
9048
+ for (const tool of reviewed) {
9049
+ const review = tool.schemaReview;
9050
+ if (!review) continue;
9051
+ const count = (change) => review.enums.filter((entry) => entry.change === change).length;
9052
+ interactive(
9053
+ writer,
9054
+ schemaReviewMessages.toolSummary({
9055
+ toolName: terminalSafeText(tool.toolName),
9056
+ total: review.enums.length,
9057
+ added: count("added"),
9058
+ changed: count("changed"),
9059
+ removed: count("removed"),
9060
+ unchanged: count("unchanged"),
9061
+ valueReviewRequired: review.humanValueReviewRequired
9062
+ })
9063
+ );
9064
+ }
9065
+ if (reviewed.some((tool) => tool.schemaReview?.humanValueReviewRequired === true)) {
9066
+ interactive(writer, schemaReviewMessages.valueReviewInWebAdmin);
9067
+ }
9068
+ }
9069
+ function candidateNeedsReviewProfile2(candidateContract) {
9070
+ return (0, import_tool_contract9.selectPublicationReviewProfile)({
9071
+ requestedProfile: CLI_PUBLICATION_REVIEW_PROFILE,
9072
+ candidateContract,
9073
+ currentTools: []
9074
+ }) === 2;
9075
+ }
9076
+ function applyPublicationWithProfile(client, projectId, idempotencyKey, body, session) {
9077
+ return session.kind === "negotiated" ? client.applyPublication(projectId, idempotencyKey, body, REVIEW_PROFILE_REQUEST) : client.applyPublication(projectId, idempotencyKey, body);
9078
+ }
8919
9079
  function writeResult(writer, result) {
8920
9080
  writeSafeJson(writer, { phase: "result", ...result });
8921
9081
  }
@@ -9008,7 +9168,13 @@ async function sendInitialApplyWithSameAnchorRetry(input) {
9008
9168
  for (let attempt = 0; attempt < INITIAL_APPLY_MAX_ATTEMPTS; attempt += 1) {
9009
9169
  try {
9010
9170
  const result = parsePublicationResult(
9011
- await input.client.applyPublication(input.projectId, input.idempotencyKey, input.body),
9171
+ await applyPublicationWithProfile(
9172
+ input.client,
9173
+ input.projectId,
9174
+ input.idempotencyKey,
9175
+ input.body,
9176
+ input.session
9177
+ ),
9012
9178
  input.plan,
9013
9179
  input.messages
9014
9180
  );
@@ -9034,7 +9200,7 @@ async function sendInitialApplyWithSameAnchorRetry(input) {
9034
9200
  return { kind: "confirmation_required", details: confirmationRequired };
9035
9201
  }
9036
9202
  if (!malformedConfirmationAnchor && !initialApplyResultMayBeUnknown(error)) {
9037
- throw remoteError(error, "initial_apply", input.messages);
9203
+ throw remoteError(error, "initial_apply", input.messages, input.schemaReviewMessages);
9038
9204
  }
9039
9205
  if (attempt === INITIAL_APPLY_MAX_ATTEMPTS - 1) {
9040
9206
  throw new PublishCommandError(
@@ -9159,7 +9325,7 @@ async function pollPublication(client, projectId, details, plan, writer, runtime
9159
9325
  }
9160
9326
  throw confirmationStopped("AP_CONFIRMATION_EXPIRED", "publication_poll_attempt_limit", messages);
9161
9327
  }
9162
- async function runPublishCommand(options, writer, cwd, runtime, messages = DEFAULT_PUBLISH_MESSAGES, scopeRegistrationMessages = DEFAULT_SCOPE_REGISTRATION_MESSAGES2) {
9328
+ async function runPublishCommand(options, writer, cwd, runtime, messages = DEFAULT_PUBLISH_MESSAGES, scopeRegistrationMessages = DEFAULT_SCOPE_REGISTRATION_MESSAGES2, schemaReviewMessages = DEFAULT_SCHEMA_REVIEW_MESSAGES) {
9163
9329
  const normalized = normalizePublishOptions(options, messages);
9164
9330
  const project = loadPublicationProject(runtime.loadProject, cwd, messages);
9165
9331
  const projectId = project.manifest.project_id;
@@ -9180,18 +9346,25 @@ async function runPublishCommand(options, writer, cwd, runtime, messages = DEFAU
9180
9346
  const client = runtime.createClient(normalized.profile);
9181
9347
  let rawPlan;
9182
9348
  try {
9183
- rawPlan = await client.planPublication(projectId, planRequest);
9349
+ rawPlan = await client.planPublication(projectId, planRequest, REVIEW_PROFILE_REQUEST);
9184
9350
  } catch (error) {
9185
- throw remoteError(error, "plan", messages);
9351
+ throw remoteError(error, "plan", messages, schemaReviewMessages);
9186
9352
  }
9353
+ const negotiated = negotiateReviewProfile(rawPlan, messages, schemaReviewMessages);
9354
+ const session = negotiated.session;
9187
9355
  const plan = parsePlan(
9188
- rawPlan,
9356
+ negotiated.body,
9189
9357
  connectorId,
9190
9358
  planRequest.candidateCommitment,
9191
9359
  expectedToolNames,
9360
+ session.profile,
9192
9361
  messages
9193
9362
  );
9194
9363
  writePlan(writer, plan);
9364
+ writeSchemaReviewSummary(writer, plan, schemaReviewMessages);
9365
+ if (session.kind === "legacy" && plan.blockedReasons.includes("opaque_change") && candidateNeedsReviewProfile2(planRequest.candidateContract)) {
9366
+ interactive(writer, schemaReviewMessages.adminApiUpdatePending);
9367
+ }
9195
9368
  if (plan.blockedReasons.includes("connector_mismatch")) {
9196
9369
  interactive(writer, messages.connectorMismatchRemediation);
9197
9370
  }
@@ -9222,7 +9395,9 @@ async function runPublishCommand(options, writer, cwd, runtime, messages = DEFAU
9222
9395
  idempotencyKey,
9223
9396
  body: initialApplyRequest,
9224
9397
  plan,
9225
- messages
9398
+ session,
9399
+ messages,
9400
+ schemaReviewMessages
9226
9401
  });
9227
9402
  let details;
9228
9403
  if (initial.kind === "response") {
@@ -9251,7 +9426,13 @@ async function runPublishCommand(options, writer, cwd, runtime, messages = DEFAU
9251
9426
  }
9252
9427
  try {
9253
9428
  const result = parsePublicationResult(
9254
- await client.applyPublication(projectId, idempotencyKey, applyRequest(decision.confirmation)),
9429
+ await applyPublicationWithProfile(
9430
+ client,
9431
+ projectId,
9432
+ idempotencyKey,
9433
+ applyRequest(decision.confirmation),
9434
+ session
9435
+ ),
9255
9436
  plan,
9256
9437
  messages,
9257
9438
  details.publicationId
@@ -9261,7 +9442,7 @@ async function runPublishCommand(options, writer, cwd, runtime, messages = DEFAU
9261
9442
  } catch (error) {
9262
9443
  if (error instanceof PublishCommandError && error.code === "AP_RESPONSE_INVALID") {
9263
9444
  } else if (!approvedApplyResultMayBeUnknown(error)) {
9264
- throw remoteError(error, "approved_apply", messages);
9445
+ throw remoteError(error, "approved_apply", messages, schemaReviewMessages);
9265
9446
  }
9266
9447
  }
9267
9448
  const recovered = await pollPublication(
@@ -9284,7 +9465,7 @@ async function runPublishCommand(options, writer, cwd, runtime, messages = DEFAU
9284
9465
  }
9285
9466
  writeResult(writer, recovered.result);
9286
9467
  }
9287
- function registerPublish(program, writer, cwd, createClient, description2 = "Tool Contract\u3092production publication workflow\u3067\u5B89\u5168\u306B\u516C\u958B\u3057\u307E\u3059", runtime = createPublishCommandRuntime(createClient), messages = DEFAULT_PUBLISH_MESSAGES, scopeRegistrationMessages = DEFAULT_SCOPE_REGISTRATION_MESSAGES2) {
9468
+ function registerPublish(program, writer, cwd, createClient, description2 = "Tool Contract\u3092production publication workflow\u3067\u5B89\u5168\u306B\u516C\u958B\u3057\u307E\u3059", runtime = createPublishCommandRuntime(createClient), messages = DEFAULT_PUBLISH_MESSAGES, scopeRegistrationMessages = DEFAULT_SCOPE_REGISTRATION_MESSAGES2, schemaReviewMessages = DEFAULT_SCHEMA_REVIEW_MESSAGES) {
9288
9469
  program.command("publish").description(description2).option("--connector <connector-uuid>", messages.connectorOption).option("--dry-run", messages.dryRunOption, false).option("--apply", messages.applyOption, false).option("--yes", messages.yesOption, false).option("--profile <name>", messages.profileOption, DEFAULT_PROFILE_NAME).option("--project <project-uuid>", messages.projectOption).action(async (commandOptions) => {
9289
9470
  await runPublishCommand(
9290
9471
  commandOptions,
@@ -9292,7 +9473,8 @@ function registerPublish(program, writer, cwd, createClient, description2 = "Too
9292
9473
  cwd(),
9293
9474
  runtime,
9294
9475
  messages,
9295
- scopeRegistrationMessages
9476
+ scopeRegistrationMessages,
9477
+ schemaReviewMessages
9296
9478
  );
9297
9479
  });
9298
9480
  }
@@ -10145,7 +10327,8 @@ function buildProgram(writer = defaultWriter, cwd = () => process.cwd(), locale
10145
10327
  text.publishDescription,
10146
10328
  void 0,
10147
10329
  messages.publish,
10148
- scopeRegistrationMessages
10330
+ scopeRegistrationMessages,
10331
+ import_localization13.PUBLICATION_SCHEMA_REVIEW_CLI_MESSAGES[locale]
10149
10332
  );
10150
10333
  return program;
10151
10334
  }
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { SupportedLocale, CliDevWorkflowMessages, CliInitWorkflowMessages, CliOAuthScopeRegistrationMessages, CliPublishWorkflowMessages } from '@andpipes/localization';
1
+ import { SupportedLocale, CliDevWorkflowMessages, CliInitWorkflowMessages, CliOAuthScopeRegistrationMessages, CliPublishWorkflowMessages, CliPublicationSchemaReviewMessages } from '@andpipes/localization';
2
2
  import { Command } from 'commander';
3
3
  import { ValidateReport, PublishGateResult, OpenApiImportUpstreamAuthMode, OpenApiImportOperationRiskOverride, OnboardingTemplateOperation, OnboardingTemplateSafeDiffEntry, ExternalSaasTemplateV1, OnboardingTemplateBindings, OAuthScopeRegistrationResponse, OAuthScopeRegistrationErrorReason } from '@andpipes/tool-contract';
4
4
  export { CheckResult, CheckStatus, RISK_LEVELS, RiskLevel, ValidateReport, validateContract } from '@andpipes/tool-contract';
@@ -529,6 +529,37 @@ declare function runInitCommand(options: InitCommandOptions, writer: Writer, cwd
529
529
  /** CLI登録。production backend adapterはfactoryとして注入し、unit testは実networkを使わない。 */
530
530
  declare function registerInit(program: Command, writer: Writer, cwd: () => string, createClient: InitApiFactory, description?: string, runtime?: InitCommandRuntime | undefined, messages?: CliInitWorkflowMessages, scopeRegistrationMessages?: CliOAuthScopeRegistrationMessages): void;
531
531
 
532
+ /**
533
+ * Publication review profile 2(#730 / ADR-730 §6.2・§6.7)のCLI側transport契約。
534
+ *
535
+ * - CLIはplan / 初回apply / 最終applyへ`Andpipe-Publication-Review-Profile: 2`(扱える最大profile)を送る。
536
+ * - plan応答のheaderはcommand層がexactに検査する。transportは生値(無ければnull)だけを返し、表示しない。
537
+ * - server error detailsの`reason`は、固定allowlistとAP codeの組が一致した場合だけ保持する。
538
+ * server message・未知details・未知reasonはCLIの表示へ転載しない。
539
+ */
540
+ /** CLI 0.1.5が扱える最大のreview profile。plan / 初回apply / 最終applyのrequest headerへ送る。 */
541
+ declare const CLI_PUBLICATION_REVIEW_PROFILE: 2;
542
+ /** plan / 初回apply / 最終applyへreview profileのrequest headerを付けるときのoption。 */
543
+ interface PublicationReviewProfileRequestOptions {
544
+ readonly reviewProfile: typeof CLI_PUBLICATION_REVIEW_PROFILE;
545
+ }
546
+ /**
547
+ * review profile headerを付けたplanのtransport応答。bodyはexact parse前の値。
548
+ * `reviewProfileHeader`はresponse headerの生値(無ければnull)で、command層が`1` / `2`だけを受理する。
549
+ */
550
+ interface PublicationPlanTransportResponse {
551
+ readonly body: unknown;
552
+ readonly reviewProfileHeader: string | null;
553
+ }
554
+ /** server error detailsから保持してよいpublication reasonと、そのreasonを返すAP code。 */
555
+ declare const PUBLICATION_ERROR_REASON_CODES: Readonly<{
556
+ readonly publication_plan_stale: "AP_CONFLICT";
557
+ readonly publication_review_profile_invalid: "AP_INPUT_INVALID";
558
+ readonly publication_schema_review_too_large: "AP_INPUT_INVALID";
559
+ readonly schema_review_receipt_mismatch: "AP_CONFLICT";
560
+ }>;
561
+ type PublicationErrorReason = keyof typeof PUBLICATION_ERROR_REASON_CODES;
562
+
532
563
  /** Admin bearer credential を送信してよい唯一の production origin。 */
533
564
  declare const ADMIN_API_ORIGIN = "https://api.andpipe.com";
534
565
  declare const ADMIN_API_TIMEOUT_MS = 10000;
@@ -569,6 +600,10 @@ interface AdminApiClientErrorSafeDetails {
569
600
  readonly scopeRegistrationReason?: OAuthScopeRegistrationErrorReason;
570
601
  /** publish gate失敗 (`scope_registration_publish_gate_failed`) の厳格検証済みtool名。 */
571
602
  readonly publishGateToolNames?: readonly string[];
603
+ /**
604
+ * tool publication (#730) の`details.reason`が固定allowlistとAP codeの組に一致した場合だけ保持する固定code。
605
+ */
606
+ readonly publicationReason?: PublicationErrorReason;
572
607
  }
573
608
  declare class AdminApiClientError extends Error {
574
609
  readonly code: string;
@@ -578,6 +613,7 @@ declare class AdminApiClientError extends Error {
578
613
  readonly detailsAbsent: boolean;
579
614
  readonly scopeRegistrationReason: OAuthScopeRegistrationErrorReason | undefined;
580
615
  readonly publishGateToolNames: readonly string[] | undefined;
616
+ readonly publicationReason: PublicationErrorReason | undefined;
581
617
  constructor(code: string, message: string, status?: number, confirmationRequired?: PublicationConfirmationRequiredDetails, openApiAuthModeMismatch?: OpenApiImportAuthModeMismatch, safeDetails?: AdminApiClientErrorSafeDetails);
582
618
  }
583
619
  declare function assertProjectId(projectId: string): string;
@@ -637,6 +673,10 @@ interface AdminPublicationApplyRequest extends AdminPublicationPlanRequest {
637
673
  readonly planCommitment: string;
638
674
  readonly confirmation: AdminPublicationConfirmation | null;
639
675
  }
676
+ /** plan / 初回apply / 最終applyへ`Andpipe-Publication-Review-Profile: 2`を送るoption (#730)。 */
677
+ type AdminPublicationReviewProfileOptions = PublicationReviewProfileRequestOptions;
678
+ /** review profile header付きplanの応答。headerの値はcommand層がexactに検査する (#730)。 */
679
+ type AdminPublicationPlanResponse = PublicationPlanTransportResponse;
640
680
  interface OpenApiImportRequest {
641
681
  readonly source: string;
642
682
  readonly connectorId: string;
@@ -1042,8 +1082,18 @@ declare class AdminApiClient {
1042
1082
  readonly config: Readonly<Record<string, unknown>> | null;
1043
1083
  readonly status: "active" | "disabled";
1044
1084
  }>;
1085
+ /**
1086
+ * `tool-publications:plan`。optionsなしは従来どおりheaderを送らずbodyだけを返す(v1)。
1087
+ * options付き (#730) は`Andpipe-Publication-Review-Profile`を送り、bodyとresponse headerの生値を返す。
1088
+ * request bodyはどちらもbyte単位で同じにする。
1089
+ */
1045
1090
  planPublication(projectId: string, body: AdminPublicationPlanRequest): Promise<unknown>;
1046
- applyPublication(projectId: string, idempotencyKey: string, body: AdminPublicationApplyRequest): Promise<unknown>;
1091
+ planPublication(projectId: string, body: AdminPublicationPlanRequest, options: AdminPublicationReviewProfileOptions): Promise<AdminPublicationPlanResponse>;
1092
+ /**
1093
+ * 初回apply(confirmation=null)と承認済みapply。options付き (#730) だけreview profile headerを送る。
1094
+ * request bodyとIdempotency-Keyはheaderの有無で変えない。
1095
+ */
1096
+ applyPublication(projectId: string, idempotencyKey: string, body: AdminPublicationApplyRequest, options?: AdminPublicationReviewProfileOptions): Promise<unknown>;
1047
1097
  planOpenApiImport(projectId: string, input: OpenApiImportRequest): Promise<OpenApiImportPlanResult>;
1048
1098
  applyOpenApiImport(projectId: string, idempotencyKey: string, input: OpenApiImportRequest): Promise<OpenApiImportDraftResult>;
1049
1099
  planOnboardingTemplate(projectId: string, manifestInput: unknown, bindingsInput: unknown): Promise<OnboardingTemplatePlanResult>;
@@ -1191,10 +1241,16 @@ interface PublicationApplyRequest extends PublicationPlanRequest {
1191
1241
  readonly planCommitment: string;
1192
1242
  readonly confirmation: PublicationConfirmation | null;
1193
1243
  }
1244
+
1194
1245
  /** Production backendはこの最小adapterへ閉じ込め、状態機械のunit testはnetworkを使わない。 */
1195
1246
  interface PublishApiClient {
1196
- planPublication(projectId: string, body: PublicationPlanRequest): Promise<unknown>;
1197
- applyPublication(projectId: string, idempotencyKey: string, body: PublicationApplyRequest): Promise<unknown>;
1247
+ /**
1248
+ * planは常に`Andpipe-Publication-Review-Profile: 2`を送り (#730)、bodyとresponse headerの生値を返す。
1249
+ * request bodyはheaderの有無で変えない。
1250
+ */
1251
+ planPublication(projectId: string, body: PublicationPlanRequest, options: PublicationReviewProfileRequestOptions): Promise<PublicationPlanTransportResponse>;
1252
+ /** optionsは新Admin API(plan応答headerが`1` / `2`)のときだけ渡す。旧Admin APIでは渡さない。 */
1253
+ applyPublication(projectId: string, idempotencyKey: string, body: PublicationApplyRequest, options?: PublicationReviewProfileRequestOptions): Promise<unknown>;
1198
1254
  getPublication(projectId: string, publicationId: string): Promise<unknown>;
1199
1255
  }
1200
1256
  type PublishApiFactory = (profile: string) => PublishApiClient;
@@ -1228,8 +1284,8 @@ declare class PublishCommandError extends Error {
1228
1284
  }
1229
1285
  declare function createPublishCommandRuntime(createClient: PublishApiFactory): PublishCommandRuntime;
1230
1286
  declare function normalizePublishOptions(options: PublishCommandOptions, messages?: CliPublishWorkflowMessages): NormalizedPublishOptions;
1231
- declare function runPublishCommand(options: PublishCommandOptions, writer: Writer, cwd: string, runtime: PublishCommandRuntime, messages?: CliPublishWorkflowMessages, scopeRegistrationMessages?: CliOAuthScopeRegistrationMessages): Promise<void>;
1232
- declare function registerPublish(program: Command, writer: Writer, cwd: () => string, createClient: PublishApiFactory, description?: string, runtime?: PublishCommandRuntime, messages?: CliPublishWorkflowMessages, scopeRegistrationMessages?: CliOAuthScopeRegistrationMessages): void;
1287
+ declare function runPublishCommand(options: PublishCommandOptions, writer: Writer, cwd: string, runtime: PublishCommandRuntime, messages?: CliPublishWorkflowMessages, scopeRegistrationMessages?: CliOAuthScopeRegistrationMessages, schemaReviewMessages?: CliPublicationSchemaReviewMessages): Promise<void>;
1288
+ declare function registerPublish(program: Command, writer: Writer, cwd: () => string, createClient: PublishApiFactory, description?: string, runtime?: PublishCommandRuntime, messages?: CliPublishWorkflowMessages, scopeRegistrationMessages?: CliOAuthScopeRegistrationMessages, schemaReviewMessages?: CliPublicationSchemaReviewMessages): void;
1233
1289
 
1234
1290
  interface BoundedFileOptions {
1235
1291
  maxBytes: number;
@@ -1404,4 +1460,4 @@ declare function redactDeep(value: unknown): unknown;
1404
1460
  /** sibling package 慣習に合わせた package 識別子 (@andpipes/* 複数形)。 */
1405
1461
  declare const packageName: "@andpipes/cli";
1406
1462
 
1407
- export { ADMIN_API_MAX_GET_ATTEMPTS, ADMIN_API_MAX_RESPONSE_BYTES, ADMIN_API_OAUTH_SCOPE_REGISTRATION_MAX_APPLY_ATTEMPTS, ADMIN_API_OAUTH_SCOPE_REGISTRATION_REQUEST_MAX_BYTES, ADMIN_API_OAUTH_SCOPE_REGISTRATION_RESPONSE_MAX_BYTES, ADMIN_API_ONBOARDING_TEMPLATE_MAX_BYTES, ADMIN_API_OPENAPI_IMPORT_MAX_BYTES, ADMIN_API_ORIGIN, ADMIN_API_PUBLICATION_REQUEST_MAX_BYTES, ADMIN_API_PUBLICATION_RESPONSE_MAX_BYTES, ADMIN_API_TIMEOUT_MS, ADMIN_CLI_AUTHORIZATION_SERVER, ADMIN_CLI_CLIENT_ID, ADMIN_CLI_HANDOFF_GRANT, ADMIN_CLI_RESOURCE, ADMIN_CLI_SCOPES, ADMIN_CLI_VERIFICATION_URI_BASE, AdminApiClient, AdminApiClientError, type AdminApiClientErrorSafeDetails, type AdminApiClientOptions, AdminCliHandoffError, type AdminCliHandoffFetch, type AdminCliHandoffRuntime, type AdminCliScope, type AdminFetch, type AdminHealth, type AdminPublicationApplyRequest, type AdminPublicationConfirmation, type AdminPublicationPlanRequest, type AdminSleep, type AuditExportDownloadAuthorization, type AuditExportIntegrity, type AuditExportListResult, type AuditExportManifest, type AuditExportSummary, CLI_NAME, CONFIG_MCP_ENDPOINT, CONFIG_MCP_HANDOFF_GRANT, CONFIG_MCP_RESOURCE, ConfigMcpClientError, type ConfigMcpConnectionConfig, type ConfigMcpCredentialRecord, type ConfigMcpFetch, ConfigMcpHandoffError, type ConfigMcpHandoffRuntime, type ConfigMcpToolSummary, ConfirmationRequiredError, type ConnectConfigMcpInput, type CreateAdminApiClientOptions, type CredentialRecord, type CredentialsFile, type CurrentAdminCredential, DEFAULT_AUTHORIZATION_SERVER, DEFAULT_DEV_PORT, DEFAULT_DEV_TTL_SECONDS, DEFAULT_PROFILE_NAME, DEFAULT_VERIFICATION_URI_BASE, type DevCommandOptions, type DevCommandRuntime, DevPolicyError, DevProjectPreflightError, type DnsRecord, type DnsSetupRecord, type DoctorCheck, type DoctorReport, type DoctorStatus, type DomainCreateResult, type DomainPlan, type HandoffFetch, type InitApiClient, type InitApiFactory, type InitCommandOptions, type InitCommandRuntime, type InitLocalPlan, InitLocalUsageError, type InitManifestCommitment, InitManifestConflictError, type InitManifestRuntime, type InitProject, type InitProjectCreateDiff, type InitProjectList, type InitRootAnchor, type InitRootIdentity, type LoadedOnboardingTemplateArtifact, type LoginAdminCliInput, type LogsResult, type NormalizedPublishOptions, type OAuthClientScopeMapRequest, type OAuthClientScopeMapResult, type OAuthClientSummary, type OAuthReadinessIssue, type OAuthScopeRegisterApi, type OAuthScopeRegisterCommandOptions, type OAuthScopeRegisterRuntime, OAuthScopeRegistrationCommandError, type OAuthScopeRegistrationRequest, type OAuthScopeRegistrationSavedDraft, type OAuthScopeRegistrationSourceInput, type OAuthScopeSummary, type OAuthScopesSyncResult, type OAuthSetupResult, type OAuthTestLoginCheck, type OAuthTestLoginResult, type OnboardingTemplateApplyRequest, type OnboardingTemplateApplyResult, type OnboardingTemplateExportResult, type OnboardingTemplatePlanResult, type OpenApiImportApi, type OpenApiImportCommandOptions, type OpenApiImportDraftResult, type OpenApiImportOperationSummary, type OpenApiImportPlanResult, type OpenApiImportRequest, type OpenApiImportRuntime, PACKAGE_NAME, type ProjectListResult, type PublicationApplyRequest, type PublicationConfirmation, type PublicationPlanRequest, type PublishApiClient, type PublishApiFactory, PublishCommandError, type PublishCommandOptions, type PublishCommandRuntime, type RandomBytes, type ReviewPackageCreateRequest, type ReviewPackageCreateResult, type ReviewPackageDownloadResult, type ReviewPackageMetadata, type SafeCustomDomain, type SafeLogEntry, type SafeProject, type TemplateApi, type TemplateCommandRuntime, UsageError, assertProjectId, assertResourceId, buildProgram, captureInitRoot, clearAll, computeDomainPlan, connectConfigMcp, createAdminApiClient, createInitCommandRuntime, createOAuthScopeRegisterRuntime, createOpenApiImportRuntime, createPublishCommandRuntime, createS256Challenge, createTemplateCommandRuntime, fetchOAuthMetadata, finalizeExistingInitManifest, generateIdempotencyKey, generatePkceVerifier, getConfigDir, getConfigMcpProfile, getCredentialsPath, getProfile, isSensitiveKey, isValidDomain, loadConfigMcpConnectionConfig, loadContract, loadOnboardingTemplateArtifact, loginAdminCli, maskSecrets, maskToken, normalizeConfigMcpScopes, normalizeDevOptions, normalizeInitOptions, normalizePublishOptions, packageName, prepareInitLocal, probeConfigMcpTools, readVersion, redactDeep, registerDev, registerInit, registerOpenApi, registerPublish, registerTemplate, removeConfigMcpProfile, removeProfile, resolveConfigMcpConnection, resolveContractPath, runCli, runDevCommand, runDoctor, runInitCommand, runOAuthScopeRegisterCommand, runOpenApiImportCommand, runPublishCommand, runTemplatePlanOrApply, runTemplateRollback, setConfigMcpProfile, setProfile, validateOAuthMetadata, writeInitManifestNoReplace };
1463
+ export { ADMIN_API_MAX_GET_ATTEMPTS, ADMIN_API_MAX_RESPONSE_BYTES, ADMIN_API_OAUTH_SCOPE_REGISTRATION_MAX_APPLY_ATTEMPTS, ADMIN_API_OAUTH_SCOPE_REGISTRATION_REQUEST_MAX_BYTES, ADMIN_API_OAUTH_SCOPE_REGISTRATION_RESPONSE_MAX_BYTES, ADMIN_API_ONBOARDING_TEMPLATE_MAX_BYTES, ADMIN_API_OPENAPI_IMPORT_MAX_BYTES, ADMIN_API_ORIGIN, ADMIN_API_PUBLICATION_REQUEST_MAX_BYTES, ADMIN_API_PUBLICATION_RESPONSE_MAX_BYTES, ADMIN_API_TIMEOUT_MS, ADMIN_CLI_AUTHORIZATION_SERVER, ADMIN_CLI_CLIENT_ID, ADMIN_CLI_HANDOFF_GRANT, ADMIN_CLI_RESOURCE, ADMIN_CLI_SCOPES, ADMIN_CLI_VERIFICATION_URI_BASE, AdminApiClient, AdminApiClientError, type AdminApiClientErrorSafeDetails, type AdminApiClientOptions, AdminCliHandoffError, type AdminCliHandoffFetch, type AdminCliHandoffRuntime, type AdminCliScope, type AdminFetch, type AdminHealth, type AdminPublicationApplyRequest, type AdminPublicationConfirmation, type AdminPublicationPlanRequest, type AdminPublicationPlanResponse, type AdminPublicationReviewProfileOptions, type AdminSleep, type AuditExportDownloadAuthorization, type AuditExportIntegrity, type AuditExportListResult, type AuditExportManifest, type AuditExportSummary, CLI_NAME, CONFIG_MCP_ENDPOINT, CONFIG_MCP_HANDOFF_GRANT, CONFIG_MCP_RESOURCE, ConfigMcpClientError, type ConfigMcpConnectionConfig, type ConfigMcpCredentialRecord, type ConfigMcpFetch, ConfigMcpHandoffError, type ConfigMcpHandoffRuntime, type ConfigMcpToolSummary, ConfirmationRequiredError, type ConnectConfigMcpInput, type CreateAdminApiClientOptions, type CredentialRecord, type CredentialsFile, type CurrentAdminCredential, DEFAULT_AUTHORIZATION_SERVER, DEFAULT_DEV_PORT, DEFAULT_DEV_TTL_SECONDS, DEFAULT_PROFILE_NAME, DEFAULT_VERIFICATION_URI_BASE, type DevCommandOptions, type DevCommandRuntime, DevPolicyError, DevProjectPreflightError, type DnsRecord, type DnsSetupRecord, type DoctorCheck, type DoctorReport, type DoctorStatus, type DomainCreateResult, type DomainPlan, type HandoffFetch, type InitApiClient, type InitApiFactory, type InitCommandOptions, type InitCommandRuntime, type InitLocalPlan, InitLocalUsageError, type InitManifestCommitment, InitManifestConflictError, type InitManifestRuntime, type InitProject, type InitProjectCreateDiff, type InitProjectList, type InitRootAnchor, type InitRootIdentity, type LoadedOnboardingTemplateArtifact, type LoginAdminCliInput, type LogsResult, type NormalizedPublishOptions, type OAuthClientScopeMapRequest, type OAuthClientScopeMapResult, type OAuthClientSummary, type OAuthReadinessIssue, type OAuthScopeRegisterApi, type OAuthScopeRegisterCommandOptions, type OAuthScopeRegisterRuntime, OAuthScopeRegistrationCommandError, type OAuthScopeRegistrationRequest, type OAuthScopeRegistrationSavedDraft, type OAuthScopeRegistrationSourceInput, type OAuthScopeSummary, type OAuthScopesSyncResult, type OAuthSetupResult, type OAuthTestLoginCheck, type OAuthTestLoginResult, type OnboardingTemplateApplyRequest, type OnboardingTemplateApplyResult, type OnboardingTemplateExportResult, type OnboardingTemplatePlanResult, type OpenApiImportApi, type OpenApiImportCommandOptions, type OpenApiImportDraftResult, type OpenApiImportOperationSummary, type OpenApiImportPlanResult, type OpenApiImportRequest, type OpenApiImportRuntime, PACKAGE_NAME, type ProjectListResult, type PublicationApplyRequest, type PublicationConfirmation, type PublicationPlanRequest, type PublicationPlanTransportResponse, type PublicationReviewProfileRequestOptions, type PublishApiClient, type PublishApiFactory, PublishCommandError, type PublishCommandOptions, type PublishCommandRuntime, type RandomBytes, type ReviewPackageCreateRequest, type ReviewPackageCreateResult, type ReviewPackageDownloadResult, type ReviewPackageMetadata, type SafeCustomDomain, type SafeLogEntry, type SafeProject, type TemplateApi, type TemplateCommandRuntime, UsageError, assertProjectId, assertResourceId, buildProgram, captureInitRoot, clearAll, computeDomainPlan, connectConfigMcp, createAdminApiClient, createInitCommandRuntime, createOAuthScopeRegisterRuntime, createOpenApiImportRuntime, createPublishCommandRuntime, createS256Challenge, createTemplateCommandRuntime, fetchOAuthMetadata, finalizeExistingInitManifest, generateIdempotencyKey, generatePkceVerifier, getConfigDir, getConfigMcpProfile, getCredentialsPath, getProfile, isSensitiveKey, isValidDomain, loadConfigMcpConnectionConfig, loadContract, loadOnboardingTemplateArtifact, loginAdminCli, maskSecrets, maskToken, normalizeConfigMcpScopes, normalizeDevOptions, normalizeInitOptions, normalizePublishOptions, packageName, prepareInitLocal, probeConfigMcpTools, readVersion, redactDeep, registerDev, registerInit, registerOpenApi, registerPublish, registerTemplate, removeConfigMcpProfile, removeProfile, resolveConfigMcpConnection, resolveContractPath, runCli, runDevCommand, runDoctor, runInitCommand, runOAuthScopeRegisterCommand, runOpenApiImportCommand, runPublishCommand, runTemplatePlanOrApply, runTemplateRollback, setConfigMcpProfile, setProfile, validateOAuthMetadata, writeInitManifestNoReplace };