@akagilnc/pi-workflow-roles 0.1.3262 → 0.1.3280

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 (35) hide show
  1. package/README.md +8 -122
  2. package/README.zh-CN.md +9 -123
  3. package/dist/gatekeeper-role.js +22 -16
  4. package/dist/grok/production-host.js +745 -571
  5. package/dist/package-contracts/gatekeeper-output.js +71 -0
  6. package/dist/package-contracts/navigator-output.js +48 -0
  7. package/dist/package-contracts/terminating-tools.js +18 -2
  8. package/dist/packaged-role-registry.js +24 -0
  9. package/dist/public-cli/config.js +7 -21
  10. package/dist/public-cli/main.js +689 -365
  11. package/dist/public-cli/registry.js +2 -14
  12. package/dist/session-opening-materials.js +6 -11
  13. package/extensions/role-runtime.ts +3 -1
  14. package/package.json +1 -1
  15. package/resources/navigator-route-playbook.md +1 -1
  16. package/src/gatekeeper-role.ts +32 -17
  17. package/src/grok/production-host.ts +3 -1
  18. package/src/host-contracts.ts +3 -1
  19. package/src/navigator-role.ts +17 -0
  20. package/src/package-contracts/gatekeeper-output.ts +89 -0
  21. package/src/package-contracts/navigator-output.ts +59 -0
  22. package/src/package-contracts/terminating-tools.ts +24 -2
  23. package/src/packaged-role-registry.ts +25 -2
  24. package/src/pi/role-turn-host.ts +4 -0
  25. package/src/public-cli/cli.ts +37 -10
  26. package/src/public-cli/config.ts +6 -30
  27. package/src/public-cli/instruction-seat-run.ts +147 -0
  28. package/src/public-cli/invocation.ts +47 -3
  29. package/src/public-cli/option-definitions.ts +36 -3
  30. package/src/public-cli/registry.ts +3 -26
  31. package/src/public-cli/run-lifecycle.ts +8 -2
  32. package/src/public-cli/settlement.ts +115 -3
  33. package/src/public-cli/terminal.ts +3 -1
  34. package/src/role-runtime.ts +64 -1
  35. package/src/session-opening-materials.ts +6 -11
@@ -1870,6 +1870,192 @@ function validateAcceptedCollectorReceipt(value) {
1870
1870
  };
1871
1871
  }
1872
1872
 
1873
+ // src/package-contracts/gatekeeper-output.ts
1874
+ import { Type as Type4 } from "typebox";
1875
+
1876
+ // src/open-tool-schema.ts
1877
+ import { Type as Type2 } from "typebox";
1878
+ function described(name, schema) {
1879
+ if (typeof schema.description === "string") return schema;
1880
+ throw new Error(`Tool field ${name} has no semantic description at its schema owner`);
1881
+ }
1882
+ function declarationIdentity(schema) {
1883
+ const { description: _description, ...semantic } = schema;
1884
+ return JSON.stringify(semantic);
1885
+ }
1886
+ function openToolObjectFromUnion(schema) {
1887
+ const declarations = /* @__PURE__ */ new Map();
1888
+ for (const variant of schema.anyOf) {
1889
+ for (const [name, declaration] of Object.entries(variant.properties ?? {})) {
1890
+ const entries = declarations.get(name) ?? [];
1891
+ const identity = declarationIdentity(declaration);
1892
+ if (!entries.some((entry) => declarationIdentity(entry) === identity)) entries.push(declaration);
1893
+ declarations.set(name, entries);
1894
+ }
1895
+ }
1896
+ const properties = Object.fromEntries([...declarations].map(([name, entries]) => {
1897
+ const descriptions = [...new Set(entries.map((entry) => entry.description).filter((value) => typeof value === "string"))].join(" ");
1898
+ const declaration = entries.length === 1 ? entries[0] : Type2.Union(entries, descriptions === "" ? {} : { description: descriptions });
1899
+ return [name, Type2.Optional(described(name, declaration))];
1900
+ }));
1901
+ const object = Type2.Object(properties, { additionalProperties: true });
1902
+ object.required = [];
1903
+ return object;
1904
+ }
1905
+ function openToolObject(schema) {
1906
+ const object = Type2.Object(
1907
+ Object.fromEntries(Object.entries(schema.properties).map(([name, declaration]) => [name, Type2.Optional(described(name, declaration))])),
1908
+ { additionalProperties: true }
1909
+ );
1910
+ object.required = [];
1911
+ return object;
1912
+ }
1913
+
1914
+ // src/package-contracts/terminating-infrastructure.ts
1915
+ import { Type as Type3 } from "typebox";
1916
+ var INFRASTRUCTURE_FAILURE_DECLARATION_KEY = "infrastructureFailure";
1917
+ var INFRASTRUCTURE_FAILURE_DIAGNOSTIC_KEY = "diagnostic";
1918
+ var infrastructureFailureDeclarationSchema = Type3.Object(
1919
+ {
1920
+ [INFRASTRUCTURE_FAILURE_DECLARATION_KEY]: Type3.Object(
1921
+ {
1922
+ [INFRASTRUCTURE_FAILURE_DIAGNOSTIC_KEY]: Type3.String({
1923
+ minLength: 1,
1924
+ description: "\u975E\u7A7A\u57FA\u7840\u8BBE\u65BD\u5931\u8D25\u8BCA\u65AD"
1925
+ })
1926
+ },
1927
+ {
1928
+ additionalProperties: true,
1929
+ description: "\u57FA\u7840\u8BBE\u65BD\u5931\u8D25\u58F0\u660E"
1930
+ }
1931
+ )
1932
+ },
1933
+ { additionalProperties: true }
1934
+ );
1935
+ function withInfrastructureFailureDeclaration(schema) {
1936
+ const baseProperties = schema.properties;
1937
+ const properties = {
1938
+ ...baseProperties ?? {},
1939
+ [INFRASTRUCTURE_FAILURE_DECLARATION_KEY]: infrastructureFailureDeclarationSchema.properties[INFRASTRUCTURE_FAILURE_DECLARATION_KEY]
1940
+ };
1941
+ const object = Type3.Object(properties, { additionalProperties: true });
1942
+ object.required = [];
1943
+ return object;
1944
+ }
1945
+ function isInfrastructureFailureDeclaration(parameters) {
1946
+ if (parameters === null || typeof parameters !== "object" || Array.isArray(parameters)) {
1947
+ return false;
1948
+ }
1949
+ const record4 = parameters;
1950
+ if (!Object.hasOwn(record4, INFRASTRUCTURE_FAILURE_DECLARATION_KEY)) return false;
1951
+ const declaration = record4[INFRASTRUCTURE_FAILURE_DECLARATION_KEY];
1952
+ if (declaration === null || typeof declaration !== "object" || Array.isArray(declaration)) {
1953
+ return false;
1954
+ }
1955
+ const diagnostic = declaration[INFRASTRUCTURE_FAILURE_DIAGNOSTIC_KEY];
1956
+ return typeof diagnostic === "string" && diagnostic.trim().length > 0;
1957
+ }
1958
+ function infrastructureFailureDiagnostic(parameters) {
1959
+ if (!isInfrastructureFailureDeclaration(parameters)) return void 0;
1960
+ const declaration = parameters[INFRASTRUCTURE_FAILURE_DECLARATION_KEY];
1961
+ const diagnostic = declaration[INFRASTRUCTURE_FAILURE_DIAGNOSTIC_KEY];
1962
+ return typeof diagnostic === "string" ? diagnostic.trim() : void 0;
1963
+ }
1964
+ function infrastructureFailureError(diagnostic) {
1965
+ const error = new Error(diagnostic);
1966
+ error.name = "InfrastructureFailure";
1967
+ return error;
1968
+ }
1969
+ function failOnInfrastructureFailureDeclaration(parameters, hostActions, ctx, toolCallId, bounceInfrastructureDeclaration) {
1970
+ const diagnostic = infrastructureFailureDiagnostic(parameters);
1971
+ if (diagnostic === void 0) return;
1972
+ if (bounceInfrastructureDeclaration !== void 0) {
1973
+ const bounce = bounceInfrastructureDeclaration(parameters, toolCallId, ctx);
1974
+ if (bounce !== void 0) throw bounce;
1975
+ }
1976
+ hostActions.failInfrastructure(
1977
+ infrastructureFailureError(diagnostic),
1978
+ ctx,
1979
+ toolCallId
1980
+ );
1981
+ }
1982
+
1983
+ // src/package-contracts/gatekeeper-output.ts
1984
+ var GATEKEEPER_OUTPUT_TOOL_NAME = "ak_gatekeeper_output";
1985
+ var GATEKEEPER_ACCEPTED_TEXT = "\u95E8\u4E0B\u7701\u51B3\u8BAE\u5DF2\u53D7\u7406";
1986
+ var gatekeeperDecisionSchema = openToolObject(
1987
+ Type4.Object({
1988
+ status: Type4.Unknown({
1989
+ description: "dispatch | pass \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8"
1990
+ }),
1991
+ officer: Type4.Unknown({
1992
+ description: "status \u4E3A dispatch \u65F6\u4E3A inspector | notary"
1993
+ }),
1994
+ findings: Type4.Unknown({
1995
+ description: "status \u4E3A pass \u65F6\u53EF\u9009 string[] findings"
1996
+ })
1997
+ })
1998
+ );
1999
+ var gatekeeperOutputSchema = withInfrastructureFailureDeclaration(
2000
+ gatekeeperDecisionSchema
2001
+ );
2002
+ function isRecord2(value) {
2003
+ return typeof value === "object" && value !== null && !Array.isArray(value);
2004
+ }
2005
+ function asStringArray(value) {
2006
+ if (!Array.isArray(value)) return [];
2007
+ return value.filter((item) => typeof item === "string");
2008
+ }
2009
+ function projectLawfulGatekeeperOutput(value) {
2010
+ if (!isRecord2(value)) return void 0;
2011
+ if (value.status === "pass") {
2012
+ return Array.isArray(value.findings) ? { status: "pass", findings: asStringArray(value.findings) } : { status: "pass" };
2013
+ }
2014
+ if (value.status === "dispatch" && (value.officer === "inspector" || value.officer === "notary")) {
2015
+ return { status: "dispatch", officer: value.officer };
2016
+ }
2017
+ return void 0;
2018
+ }
2019
+ function validateRecordedGatekeeperOutput(value) {
2020
+ const projected = projectLawfulGatekeeperOutput(value);
2021
+ if (projected === void 0) {
2022
+ throw new Error("Gatekeeper output has no recognized execution discriminator");
2023
+ }
2024
+ return projected;
2025
+ }
2026
+
2027
+ // src/package-contracts/navigator-output.ts
2028
+ import { Type as Type5 } from "typebox";
2029
+ var NAVIGATOR_OUTPUT_TOOL_NAME = "ak_navigator_output";
2030
+ var NAVIGATOR_ACCEPTED_TEXT = "\u6E38\u5955\u4F7F\u5EFA\u8BAE\u5DF2\u53D7\u7406";
2031
+ var navigatorOutputSchema = withInfrastructureFailureDeclaration(
2032
+ openToolObject(
2033
+ Type5.Object({
2034
+ status: Type5.Unknown({
2035
+ description: "advice \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8"
2036
+ }),
2037
+ candidates: Type5.Unknown({
2038
+ description: "\u6392\u597D\u5E8F\u7684\u8DEF\u7EBF\u5EFA\u8BAE\u6570\u7EC4\uFF0C\u5143\u7D20\u542B next/phase/reason \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8"
2039
+ })
2040
+ })
2041
+ )
2042
+ );
2043
+ function isRecord3(value) {
2044
+ return typeof value === "object" && value !== null && !Array.isArray(value);
2045
+ }
2046
+ function projectLawfulNavigatorOutput(value) {
2047
+ if (!isRecord3(value) || !Array.isArray(value.candidates)) return void 0;
2048
+ if (value.status !== "advice") return void 0;
2049
+ return { status: "advice", candidates: value.candidates.filter(isRecord3) };
2050
+ }
2051
+ function validateRecordedNavigatorOutput(value) {
2052
+ const projected = projectLawfulNavigatorOutput(value);
2053
+ if (projected === void 0) {
2054
+ throw new Error("Navigator output has no recognized execution discriminator");
2055
+ }
2056
+ return projected;
2057
+ }
2058
+
1873
2059
  // src/package-contracts/judge-output.ts
1874
2060
  var JUDGE_OUTPUT_TOOL_NAME = "ak_judge_output";
1875
2061
  var JUDGE_ACCEPTED_TEXT = "\u5927\u7406\u5BFA\u56DE\u6267\u5DF2\u63A5\u53D7";
@@ -1894,11 +2080,11 @@ function validateAcceptedJudgeDetails(verdict) {
1894
2080
  // src/package-contracts/reviewer-output.ts
1895
2081
  var REVIEWER_OUTPUT_TOOL_NAME = "ak_reviewer_output";
1896
2082
  var REVIEWER_ACCEPTED_TEXT = "\u5FA1\u53F2\u53F0\u56DE\u6267\u5DF2\u63A5\u53D7";
1897
- function isRecord2(value) {
2083
+ function isRecord4(value) {
1898
2084
  return typeof value === "object" && value !== null && !Array.isArray(value);
1899
2085
  }
1900
2086
  function read(value, key) {
1901
- if (!isRecord2(value)) return void 0;
2087
+ if (!isRecord4(value)) return void 0;
1902
2088
  try {
1903
2089
  return value[key];
1904
2090
  } catch {
@@ -1907,7 +2093,7 @@ function read(value, key) {
1907
2093
  }
1908
2094
  function readAmendments(output) {
1909
2095
  const amendments = read(output, "amendments");
1910
- if (!isRecord2(amendments)) return void 0;
2096
+ if (!isRecord4(amendments)) return void 0;
1911
2097
  const slots = {};
1912
2098
  for (const axis of ["standards", "spec"]) {
1913
2099
  const value = read(amendments, axis);
@@ -1937,25 +2123,25 @@ function validateRuntimeReviewerReceipt(output) {
1937
2123
  const outcomes = read(output, "outcomes");
1938
2124
  const legs = read(acceptedBatch, "legs");
1939
2125
  if (acceptedBatch !== void 0 || construction !== void 0 || target !== void 0) {
1940
- if (!isRecord2(acceptedBatch) || !isRecord2(construction) || !isRecord2(target) || !Array.isArray(legs))
2126
+ if (!isRecord4(acceptedBatch) || !isRecord4(construction) || !isRecord4(target) || !Array.isArray(legs))
1941
2127
  throw new Error("Incomplete Reviewer accepted-batch identity");
1942
2128
  const objectFormat = read(target, "objectFormat");
1943
2129
  const objectId = (value) => typeof value === "string" && new RegExp(objectFormat === "sha1" ? "^[0-9a-f]{40}$" : "^[0-9a-f]{64}$").test(value);
1944
2130
  const refs = read(target, "refs");
1945
2131
  const skillText = read(read(identities, "canonicalSkill"), "text");
1946
- if (typeof skillText !== "string" || read(construction, "recipe") !== "reviewer-common-bundle-v1" || objectFormat !== "sha1" && objectFormat !== "sha256" || !objectId(read(target, "targetHead")) || !isRecord2(refs) || Object.values(refs).some((ref) => !isRecord2(ref) || !objectId(read(ref, "objectId")) || read(ref, "peeledCommitId") !== null && !objectId(read(ref, "peeledCommitId"))))
2132
+ if (typeof skillText !== "string" || read(construction, "recipe") !== "reviewer-common-bundle-v1" || objectFormat !== "sha1" && objectFormat !== "sha256" || !objectId(read(target, "targetHead")) || !isRecord4(refs) || Object.values(refs).some((ref) => !isRecord4(ref) || !objectId(read(ref, "objectId")) || read(ref, "peeledCommitId") !== null && !objectId(read(ref, "peeledCommitId"))))
1947
2133
  throw new Error("Invalid Reviewer construction or target identity");
1948
2134
  const expectedAxes = legs.map((leg) => read(leg, "axis"));
1949
2135
  if (expectedAxes[0] !== "standards" || expectedAxes.length === 2 && expectedAxes[1] !== "spec" || expectedAxes.length < 1 || expectedAxes.length > 2)
1950
2136
  throw new Error("Invalid Reviewer accepted-leg projection");
1951
- if (!isRecord2(outcomes) || !isRecord2(reports)) throw new Error("Accepted Reviewer batch lacks outcomes or reports");
2137
+ if (!isRecord4(outcomes) || !isRecord4(reports)) throw new Error("Accepted Reviewer batch lacks outcomes or reports");
1952
2138
  const outcomeAxes = Object.keys(outcomes).filter((axis) => axis === "standards" || axis === "spec");
1953
2139
  if (outcomeAxes.length !== expectedAxes.length || outcomeAxes.some((axis, index) => axis !== expectedAxes[index]))
1954
2140
  throw new Error("Reviewer outcomes must exactly cover accepted legs in canonical order");
1955
2141
  for (const [index, axisValue] of expectedAxes.entries()) {
1956
2142
  const axis = axisValue;
1957
2143
  const outcome = read(outcomes, axis);
1958
- if (!isRecord2(outcome)) throw new Error("Reviewer accepted leg lacks outcome");
2144
+ if (!isRecord4(outcome)) throw new Error("Reviewer accepted leg lacks outcome");
1959
2145
  const expectedPrompt = read(read(legs[index], "prompt"), "text");
1960
2146
  const actualPrompt = read(read(outcome, "prompt"), "text");
1961
2147
  if (expectedPrompt !== actualPrompt) throw new Error("Reviewer outcome prompt disagrees with accepted leg");
@@ -1982,17 +2168,17 @@ function validateRuntimeReviewerReceipt(output) {
1982
2168
  }
1983
2169
 
1984
2170
  // src/package-contracts/fixer-output.ts
1985
- import { Type as Type5 } from "typebox";
2171
+ import { Type as Type7 } from "typebox";
1986
2172
 
1987
2173
  // src/package-contracts/fixer-packet.ts
1988
- import { Type as Type2 } from "typebox";
2174
+ import { Type as Type6 } from "typebox";
1989
2175
  import { Value } from "typebox/value";
1990
2176
  var FIXER_PREREQUISITE_ID_PATTERN = "^[A-Za-z0-9][A-Za-z0-9._-]*$";
1991
- var fixerPrerequisiteSchema = Type2.Object({
1992
- id: Type2.String({ pattern: FIXER_PREREQUISITE_ID_PATTERN }),
1993
- requirement: Type2.String({ pattern: "\\S" })
2177
+ var fixerPrerequisiteSchema = Type6.Object({
2178
+ id: Type6.String({ pattern: FIXER_PREREQUISITE_ID_PATTERN }),
2179
+ requirement: Type6.String({ pattern: "\\S" })
1994
2180
  }, { additionalProperties: false });
1995
- var fixerPrerequisitesSchema = Type2.Array(fixerPrerequisiteSchema);
2181
+ var fixerPrerequisitesSchema = Type6.Array(fixerPrerequisiteSchema);
1996
2182
  function causeMessage(cause) {
1997
2183
  if (cause instanceof Error) return cause.message;
1998
2184
  if (typeof cause === "string") return cause;
@@ -2058,148 +2244,41 @@ function parseFixerPrerequisites(source) {
2058
2244
  return validateFixerPrerequisites(decoded);
2059
2245
  }
2060
2246
 
2061
- // src/open-tool-schema.ts
2062
- import { Type as Type3 } from "typebox";
2063
- function described(name, schema) {
2064
- if (typeof schema.description === "string") return schema;
2065
- throw new Error(`Tool field ${name} has no semantic description at its schema owner`);
2066
- }
2067
- function declarationIdentity(schema) {
2068
- const { description: _description, ...semantic } = schema;
2069
- return JSON.stringify(semantic);
2070
- }
2071
- function openToolObjectFromUnion(schema) {
2072
- const declarations = /* @__PURE__ */ new Map();
2073
- for (const variant of schema.anyOf) {
2074
- for (const [name, declaration] of Object.entries(variant.properties ?? {})) {
2075
- const entries = declarations.get(name) ?? [];
2076
- const identity = declarationIdentity(declaration);
2077
- if (!entries.some((entry) => declarationIdentity(entry) === identity)) entries.push(declaration);
2078
- declarations.set(name, entries);
2079
- }
2080
- }
2081
- const properties = Object.fromEntries([...declarations].map(([name, entries]) => {
2082
- const descriptions = [...new Set(entries.map((entry) => entry.description).filter((value) => typeof value === "string"))].join(" ");
2083
- const declaration = entries.length === 1 ? entries[0] : Type3.Union(entries, descriptions === "" ? {} : { description: descriptions });
2084
- return [name, Type3.Optional(described(name, declaration))];
2085
- }));
2086
- const object = Type3.Object(properties, { additionalProperties: true });
2087
- object.required = [];
2088
- return object;
2089
- }
2090
- function openToolObject(schema) {
2091
- const object = Type3.Object(
2092
- Object.fromEntries(Object.entries(schema.properties).map(([name, declaration]) => [name, Type3.Optional(described(name, declaration))])),
2093
- { additionalProperties: true }
2094
- );
2095
- object.required = [];
2096
- return object;
2097
- }
2098
-
2099
- // src/package-contracts/terminating-infrastructure.ts
2100
- import { Type as Type4 } from "typebox";
2101
- var INFRASTRUCTURE_FAILURE_DECLARATION_KEY = "infrastructureFailure";
2102
- var INFRASTRUCTURE_FAILURE_DIAGNOSTIC_KEY = "diagnostic";
2103
- var infrastructureFailureDeclarationSchema = Type4.Object(
2104
- {
2105
- [INFRASTRUCTURE_FAILURE_DECLARATION_KEY]: Type4.Object(
2106
- {
2107
- [INFRASTRUCTURE_FAILURE_DIAGNOSTIC_KEY]: Type4.String({
2108
- minLength: 1,
2109
- description: "\u975E\u7A7A\u57FA\u7840\u8BBE\u65BD\u5931\u8D25\u8BCA\u65AD"
2110
- })
2111
- },
2112
- {
2113
- additionalProperties: true,
2114
- description: "\u57FA\u7840\u8BBE\u65BD\u5931\u8D25\u58F0\u660E"
2115
- }
2116
- )
2117
- },
2118
- { additionalProperties: true }
2119
- );
2120
- function withInfrastructureFailureDeclaration(schema) {
2121
- const baseProperties = schema.properties;
2122
- const properties = {
2123
- ...baseProperties ?? {},
2124
- [INFRASTRUCTURE_FAILURE_DECLARATION_KEY]: infrastructureFailureDeclarationSchema.properties[INFRASTRUCTURE_FAILURE_DECLARATION_KEY]
2125
- };
2126
- const object = Type4.Object(properties, { additionalProperties: true });
2127
- object.required = [];
2128
- return object;
2129
- }
2130
- function isInfrastructureFailureDeclaration(parameters) {
2131
- if (parameters === null || typeof parameters !== "object" || Array.isArray(parameters)) {
2132
- return false;
2133
- }
2134
- const record4 = parameters;
2135
- if (!Object.hasOwn(record4, INFRASTRUCTURE_FAILURE_DECLARATION_KEY)) return false;
2136
- const declaration = record4[INFRASTRUCTURE_FAILURE_DECLARATION_KEY];
2137
- if (declaration === null || typeof declaration !== "object" || Array.isArray(declaration)) {
2138
- return false;
2139
- }
2140
- const diagnostic = declaration[INFRASTRUCTURE_FAILURE_DIAGNOSTIC_KEY];
2141
- return typeof diagnostic === "string" && diagnostic.trim().length > 0;
2142
- }
2143
- function infrastructureFailureDiagnostic(parameters) {
2144
- if (!isInfrastructureFailureDeclaration(parameters)) return void 0;
2145
- const declaration = parameters[INFRASTRUCTURE_FAILURE_DECLARATION_KEY];
2146
- const diagnostic = declaration[INFRASTRUCTURE_FAILURE_DIAGNOSTIC_KEY];
2147
- return typeof diagnostic === "string" ? diagnostic.trim() : void 0;
2148
- }
2149
- function infrastructureFailureError(diagnostic) {
2150
- const error = new Error(diagnostic);
2151
- error.name = "InfrastructureFailure";
2152
- return error;
2153
- }
2154
- function failOnInfrastructureFailureDeclaration(parameters, hostActions, ctx, toolCallId, bounceInfrastructureDeclaration) {
2155
- const diagnostic = infrastructureFailureDiagnostic(parameters);
2156
- if (diagnostic === void 0) return;
2157
- if (bounceInfrastructureDeclaration !== void 0) {
2158
- const bounce = bounceInfrastructureDeclaration(parameters, toolCallId, ctx);
2159
- if (bounce !== void 0) throw bounce;
2160
- }
2161
- hostActions.failInfrastructure(
2162
- infrastructureFailureError(diagnostic),
2163
- ctx,
2164
- toolCallId
2165
- );
2166
- }
2167
-
2168
2247
  // src/package-contracts/fixer-output.ts
2169
2248
  var FIXER_OUTPUT_TOOL_NAME = "ak_fixer_output";
2170
2249
  var FIXER_ACCEPTED_TEXT = "\u4FEE\u5185\u53F8\u56DE\u6267\u5DF2\u63A5\u53D7";
2171
- var nonblankTransportString = Type5.String({ minLength: 1 });
2172
- var authorityBlockerSchema = Type5.Object({ cause: Type5.Literal("authority_violation"), evidence: nonblankTransportString });
2173
- var prerequisiteBlockerSchema = Type5.Object({ cause: Type5.Literal("prerequisite_unmet"), prerequisiteId: Type5.String({ pattern: FIXER_PREREQUISITE_ID_PATTERN }), evidence: nonblankTransportString });
2174
- var blockerSchema = Type5.Union([authorityBlockerSchema, prerequisiteBlockerSchema]);
2175
- var exceptionSchema = Type5.Object({ where: nonblankTransportString, reason: nonblankTransportString });
2176
- var testEvidenceSchema = Type5.Object({
2177
- contract: Type5.String({ minLength: 1, description: "\u6D4B\u8BD5\u6539\u52A8\u6240\u8BC1\u660E\u7684\u5951\u7EA6" }),
2178
- minimumNecessaryCost: Type5.String({ minLength: 1, description: "\u6D4B\u8BD5\u6539\u52A8\u7684\u4E00\u884C\u6700\u5C0F\u5FC5\u8981\u6210\u672C" }),
2179
- measuredDuration: Type5.String({ minLength: 1, description: "\u805A\u7126\u9A8C\u8BC1\u5B9E\u6D4B\u65F6\u957F" })
2250
+ var nonblankTransportString = Type7.String({ minLength: 1 });
2251
+ var authorityBlockerSchema = Type7.Object({ cause: Type7.Literal("authority_violation"), evidence: nonblankTransportString });
2252
+ var prerequisiteBlockerSchema = Type7.Object({ cause: Type7.Literal("prerequisite_unmet"), prerequisiteId: Type7.String({ pattern: FIXER_PREREQUISITE_ID_PATTERN }), evidence: nonblankTransportString });
2253
+ var blockerSchema = Type7.Union([authorityBlockerSchema, prerequisiteBlockerSchema]);
2254
+ var exceptionSchema = Type7.Object({ where: nonblankTransportString, reason: nonblankTransportString });
2255
+ var testEvidenceSchema = Type7.Object({
2256
+ contract: Type7.String({ minLength: 1, description: "\u6D4B\u8BD5\u6539\u52A8\u6240\u8BC1\u660E\u7684\u5951\u7EA6" }),
2257
+ minimumNecessaryCost: Type7.String({ minLength: 1, description: "\u6D4B\u8BD5\u6539\u52A8\u7684\u4E00\u884C\u6700\u5C0F\u5FC5\u8981\u6210\u672C" }),
2258
+ measuredDuration: Type7.String({ minLength: 1, description: "\u805A\u7126\u9A8C\u8BC1\u5B9E\u6D4B\u65F6\u957F" })
2180
2259
  }, { description: "\u6D4B\u8BD5\u8BC1\u636E\u6761\uFF1Bdiff \u542B\u6D4B\u8BD5\u6539\u52A8\u65F6\u63D0\u4EA4\uFF1B\u673A\u5668\u4E0D\u6838\u9A8C\u3002" });
2181
- var completedClassResultSchema = Type5.Object({
2260
+ var completedClassResultSchema = Type7.Object({
2182
2261
  name: nonblankTransportString,
2183
- disposition: Type5.Literal("completed"),
2262
+ disposition: Type7.Literal("completed"),
2184
2263
  searchScope: nonblankTransportString,
2185
- exceptions: Type5.Array(exceptionSchema),
2264
+ exceptions: Type7.Array(exceptionSchema),
2186
2265
  commitSha: nonblankTransportString
2187
2266
  });
2188
- var refusedClassResultSchema = Type5.Object({
2267
+ var refusedClassResultSchema = Type7.Object({
2189
2268
  name: nonblankTransportString,
2190
- disposition: Type5.Literal("refused"),
2269
+ disposition: Type7.Literal("refused"),
2191
2270
  remainingScope: nonblankTransportString,
2192
2271
  blocker: blockerSchema
2193
2272
  });
2194
- var classResultSchema = Type5.Union([completedClassResultSchema, refusedClassResultSchema]);
2195
- var completedClassResultsSchema = Type5.Array(completedClassResultSchema, { minItems: 1 });
2196
- var fixerOutputVariants = Type5.Union([
2197
- Type5.Object({ status: Type5.Literal("planned", { description: "planned \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8" }), report: Type5.String({ minLength: 1, description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }) }),
2198
- Type5.Object({ status: Type5.Literal("refused", { description: "refused \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8" }), report: Type5.String({ minLength: 1, description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }), remainingScope: Type5.String({ minLength: 1, description: "\u4F9D\u6CD5\u4E0D\u80FD\u5B8C\u6210\u7684\u5DE5\u4F5C\u8303\u56F4" }), blocker: Type5.Unsafe({ ...blockerSchema, description: "\u5408\u6CD5\u963B\u65AD\u5B8C\u6210\u7684 blocker" }) }),
2199
- Type5.Object({ status: Type5.Literal("unfinished", { description: "unfinished \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8\uFF1B\u7F3A\u524D\u7F6E\u6216\u8FDD\u5BAA\u7EA6\u675F\u81F4\u672C\u5C40\u672A\u5B8C\u6210\u65F6\u53EF\u7528\u3002\u7F3A\u5F85\u51B3 owner \u51B3\u5B9A\u6216\u7B54\u590D\u5C5E\u7F3A\u524D\u7F6E\u3002" }), report: Type5.String({ minLength: 1, description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }), remainingScope: Type5.String({ minLength: 1, description: "\u672C\u5C40\u540E\u5269\u4F59\u5DE5\u4F5C" }), reason: Type5.Optional(Type5.String({ minLength: 1, description: "\u963B\u65AD\u539F\u56E0\uFF1A\u7F3A\u524D\u7F6E\u6216\u8FDD\u5BAA\u7EA6\u675F\u3002\u7F3A\u5F85\u51B3 owner \u51B3\u5B9A\u6216\u7B54\u590D\u5C5E\u7F3A\u524D\u7F6E\u3002" })), classResults: Type5.Optional(Type5.Unsafe({ ...completedClassResultsSchema, description: "\u672C\u5C40\u5DF2\u5B8C\u6210\u7684 class \u7ED3\u7B97" })), testEvidence: Type5.Optional(testEvidenceSchema) }),
2200
- Type5.Object({ status: Type5.Literal("completed", { description: "completed \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8" }), report: Type5.String({ minLength: 1, description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }), classResults: Type5.Array(classResultSchema, { minItems: 1, description: "\u5DF2\u5B8C\u6210\u7684 class \u7ED3\u7B97" }), testEvidence: Type5.Optional(testEvidenceSchema) }),
2201
- Type5.Object({ status: Type5.Literal("refused", { description: "refused \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8" }), report: Type5.String({ minLength: 1, description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }), classResults: Type5.Array(classResultSchema, { minItems: 1, description: "\u5404\u7C7B\u62D2\u7EDD\u7ED3\u7B97" }) }),
2202
- Type5.Object({ status: Type5.Literal("partially_completed", { description: "partially_completed \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8" }), report: Type5.String({ minLength: 1, description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }), classResults: Type5.Array(classResultSchema, { minItems: 1, description: "\u5404\u7C7B\u5B8C\u6210\u6216\u62D2\u7EDD\u7ED3\u7B97" }), testEvidence: Type5.Optional(testEvidenceSchema) })
2273
+ var classResultSchema = Type7.Union([completedClassResultSchema, refusedClassResultSchema]);
2274
+ var completedClassResultsSchema = Type7.Array(completedClassResultSchema, { minItems: 1 });
2275
+ var fixerOutputVariants = Type7.Union([
2276
+ Type7.Object({ status: Type7.Literal("planned", { description: "planned \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8" }), report: Type7.String({ minLength: 1, description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }) }),
2277
+ Type7.Object({ status: Type7.Literal("refused", { description: "refused \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8" }), report: Type7.String({ minLength: 1, description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }), remainingScope: Type7.String({ minLength: 1, description: "\u4F9D\u6CD5\u4E0D\u80FD\u5B8C\u6210\u7684\u5DE5\u4F5C\u8303\u56F4" }), blocker: Type7.Unsafe({ ...blockerSchema, description: "\u5408\u6CD5\u963B\u65AD\u5B8C\u6210\u7684 blocker" }) }),
2278
+ Type7.Object({ status: Type7.Literal("unfinished", { description: "unfinished \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8\uFF1B\u7F3A\u524D\u7F6E\u6216\u8FDD\u5BAA\u7EA6\u675F\u81F4\u672C\u5C40\u672A\u5B8C\u6210\u65F6\u53EF\u7528\u3002\u7F3A\u5F85\u51B3 owner \u51B3\u5B9A\u6216\u7B54\u590D\u5C5E\u7F3A\u524D\u7F6E\u3002" }), report: Type7.String({ minLength: 1, description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }), remainingScope: Type7.String({ minLength: 1, description: "\u672C\u5C40\u540E\u5269\u4F59\u5DE5\u4F5C" }), reason: Type7.Optional(Type7.String({ minLength: 1, description: "\u963B\u65AD\u539F\u56E0\uFF1A\u7F3A\u524D\u7F6E\u6216\u8FDD\u5BAA\u7EA6\u675F\u3002\u7F3A\u5F85\u51B3 owner \u51B3\u5B9A\u6216\u7B54\u590D\u5C5E\u7F3A\u524D\u7F6E\u3002" })), classResults: Type7.Optional(Type7.Unsafe({ ...completedClassResultsSchema, description: "\u672C\u5C40\u5DF2\u5B8C\u6210\u7684 class \u7ED3\u7B97" })), testEvidence: Type7.Optional(testEvidenceSchema) }),
2279
+ Type7.Object({ status: Type7.Literal("completed", { description: "completed \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8" }), report: Type7.String({ minLength: 1, description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }), classResults: Type7.Array(classResultSchema, { minItems: 1, description: "\u5DF2\u5B8C\u6210\u7684 class \u7ED3\u7B97" }), testEvidence: Type7.Optional(testEvidenceSchema) }),
2280
+ Type7.Object({ status: Type7.Literal("refused", { description: "refused \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8" }), report: Type7.String({ minLength: 1, description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }), classResults: Type7.Array(classResultSchema, { minItems: 1, description: "\u5404\u7C7B\u62D2\u7EDD\u7ED3\u7B97" }) }),
2281
+ Type7.Object({ status: Type7.Literal("partially_completed", { description: "partially_completed \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8" }), report: Type7.String({ minLength: 1, description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }), classResults: Type7.Array(classResultSchema, { minItems: 1, description: "\u5404\u7C7B\u5B8C\u6210\u6216\u62D2\u7EDD\u7ED3\u7B97" }), testEvidence: Type7.Optional(testEvidenceSchema) })
2203
2282
  ]);
2204
2283
  var fixerOutputSchema = withInfrastructureFailureDeclaration(
2205
2284
  openToolObjectFromUnion(fixerOutputVariants)
@@ -2242,7 +2321,7 @@ function validateAcceptedWorkerDetails(output, roleLabel = "Coder") {
2242
2321
  }
2243
2322
 
2244
2323
  // src/doctor-contracts.ts
2245
- import { Type as Type6 } from "typebox";
2324
+ import { Type as Type8 } from "typebox";
2246
2325
 
2247
2326
  // src/canonical-json.ts
2248
2327
  var CANONICAL_JSON_VALIDATION_ERROR_CODE = "canonical-json-invalid";
@@ -2319,70 +2398,70 @@ var DOCTOR_ACCEPTED_TEXT = "\u592A\u533B\u7F72\u56DE\u6267\u5DF2\u63A5\u53D7";
2319
2398
  var DOCTOR_ACCEPTED_AUDIT_NO_RECEIPT_TEXT = "\u592A\u533B\u7F72\u56DE\u6267\u5DF2\u63A5\u53D7\uFF1B\u5BA1\u8BA1\u65E0\u56DE\u6267";
2320
2399
  var DOCTOR_OUTPUT_TOOL_DESCRIPTION = "\u63D0\u4EA4\u552F\u4E00\u7EC8\u5C40\u5355\u6848\u8BC1\u8BCD\uFF1Bcompleted \u5141\u8BB8\u7A7A findings\uFF1Bruntime \u8865\u8BB0\u6D3E\u751F\u6210\u672C\u5165\u56DE\u6267\u3002";
2321
2400
  var DOCTOR_TARGET_KINDS = ["law", "gate", "template", "station", "seat"];
2322
- var nonblank = Type6.String({ minLength: 1, pattern: "\\S" });
2323
- var count = Type6.Object({ count: Type6.Integer({ minimum: 0 }), sources: Type6.Array(nonblank) }, { additionalProperties: false });
2324
- var evidenceIds = Type6.Array(nonblank, { minItems: 1 });
2325
- var guardrail = Type6.Object({ answer: Type6.Boolean(), evidenceIds, explanation: nonblank }, { additionalProperties: false });
2326
- var lastRealBite = Type6.Union([
2327
- Type6.Object({ kind: Type6.Literal("actual"), targetKey: nonblank, evidenceId: nonblank }, { additionalProperties: false }),
2328
- Type6.Object({ kind: Type6.Literal("noRealBite"), targetKey: nonblank, eligibleEvidenceIds: evidenceIds }, { additionalProperties: false })
2401
+ var nonblank = Type8.String({ minLength: 1, pattern: "\\S" });
2402
+ var count = Type8.Object({ count: Type8.Integer({ minimum: 0 }), sources: Type8.Array(nonblank) }, { additionalProperties: false });
2403
+ var evidenceIds = Type8.Array(nonblank, { minItems: 1 });
2404
+ var guardrail = Type8.Object({ answer: Type8.Boolean(), evidenceIds, explanation: nonblank }, { additionalProperties: false });
2405
+ var lastRealBite = Type8.Union([
2406
+ Type8.Object({ kind: Type8.Literal("actual"), targetKey: nonblank, evidenceId: nonblank }, { additionalProperties: false }),
2407
+ Type8.Object({ kind: Type8.Literal("noRealBite"), targetKey: nonblank, eligibleEvidenceIds: evidenceIds }, { additionalProperties: false })
2329
2408
  ]);
2330
2409
  var assetKinds = DOCTOR_TARGET_KINDS;
2331
2410
  var findingBody = {
2332
2411
  evidenceIds,
2333
- disposition: Type6.Union([Type6.Literal("keep"), Type6.Literal("thin"), Type6.Literal("delete")]),
2334
- guardrails: Type6.Object({ reproducibleFailure: guardrail, owningSeamOrInvariant: guardrail, deletionOrSimplificationSuffices: guardrail }, { additionalProperties: true }),
2335
- prescription: Type6.Object({ kind: Type6.Union([Type6.Literal("retain"), Type6.Literal("delete"), Type6.Literal("simplify"), Type6.Literal("patch"), Type6.Literal("addMechanism")]), recommendation: nonblank, necessityExplanation: Type6.Optional(nonblank) }, { additionalProperties: false }),
2412
+ disposition: Type8.Union([Type8.Literal("keep"), Type8.Literal("thin"), Type8.Literal("delete")]),
2413
+ guardrails: Type8.Object({ reproducibleFailure: guardrail, owningSeamOrInvariant: guardrail, deletionOrSimplificationSuffices: guardrail }, { additionalProperties: true }),
2414
+ prescription: Type8.Object({ kind: Type8.Union([Type8.Literal("retain"), Type8.Literal("delete"), Type8.Literal("simplify"), Type8.Literal("patch"), Type8.Literal("addMechanism")]), recommendation: nonblank, necessityExplanation: Type8.Optional(nonblank) }, { additionalProperties: false }),
2336
2415
  lastRealBite
2337
2416
  };
2338
- var finding = Type6.Union([
2339
- Type6.Object({ targetKey: nonblank, observation: nonblank, evidenceIds }, { additionalProperties: false }),
2340
- Type6.Object({ targetKey: nonblank, targetKind: Type6.Union(assetKinds.map((kind) => Type6.Literal(kind))), assetEvidence: Type6.Object({ targetKey: nonblank, targetKind: Type6.Union(assetKinds.map((kind) => Type6.Literal(kind))), evidenceId: nonblank }, { additionalProperties: false }), ...findingBody }, { additionalProperties: false })
2417
+ var finding = Type8.Union([
2418
+ Type8.Object({ targetKey: nonblank, observation: nonblank, evidenceIds }, { additionalProperties: false }),
2419
+ Type8.Object({ targetKey: nonblank, targetKind: Type8.Union(assetKinds.map((kind) => Type8.Literal(kind))), assetEvidence: Type8.Object({ targetKey: nonblank, targetKind: Type8.Union(assetKinds.map((kind) => Type8.Literal(kind))), evidenceId: nonblank }, { additionalProperties: false }), ...findingBody }, { additionalProperties: false })
2341
2420
  ]);
2342
- var caseIdentity = Type6.Object({ issueNumber: Type6.Integer({ minimum: 1 }), runsPath: nonblank }, { additionalProperties: false });
2343
- var cost = Type6.Object({
2421
+ var caseIdentity = Type8.Object({ issueNumber: Type8.Integer({ minimum: 1 }), runsPath: nonblank }, { additionalProperties: false });
2422
+ var cost = Type8.Object({
2344
2423
  invocations: count,
2345
2424
  legs: count,
2346
2425
  modelApiTurns: count,
2347
2426
  outputTokens: count,
2348
2427
  toolCalls: count,
2349
- retries: Type6.Object({ count: Type6.Integer({ minimum: 0 }), sources: Type6.Array(nonblank), evidence: Type6.Literal("literal run-dir naming") }, { additionalProperties: false }),
2350
- statuses: Type6.Array(Type6.Object({ source: nonblank, status: nonblank }, { additionalProperties: false })),
2351
- commits: Type6.Array(Type6.Object({ source: nonblank, commit: nonblank }, { additionalProperties: false })),
2352
- sessions: Type6.Array(Type6.Union([
2353
- Type6.Object({ source: nonblank, startedAt: nonblank, endedAt: nonblank, wallMilliseconds: Type6.Number({ minimum: 0 }), completion: Type6.Literal("accepted") }, { additionalProperties: false }),
2354
- Type6.Object({ source: nonblank, startedAt: Type6.Optional(nonblank), endedAt: Type6.Optional(nonblank), wallMilliseconds: Type6.Optional(Type6.Number({ minimum: 0 })), completion: Type6.Literal("incomplete"), degradationReason: Type6.Optional(nonblank) }, { additionalProperties: false })
2428
+ retries: Type8.Object({ count: Type8.Integer({ minimum: 0 }), sources: Type8.Array(nonblank), evidence: Type8.Literal("literal run-dir naming") }, { additionalProperties: false }),
2429
+ statuses: Type8.Array(Type8.Object({ source: nonblank, status: nonblank }, { additionalProperties: false })),
2430
+ commits: Type8.Array(Type8.Object({ source: nonblank, commit: nonblank }, { additionalProperties: false })),
2431
+ sessions: Type8.Array(Type8.Union([
2432
+ Type8.Object({ source: nonblank, startedAt: nonblank, endedAt: nonblank, wallMilliseconds: Type8.Number({ minimum: 0 }), completion: Type8.Literal("accepted") }, { additionalProperties: false }),
2433
+ Type8.Object({ source: nonblank, startedAt: Type8.Optional(nonblank), endedAt: Type8.Optional(nonblank), wallMilliseconds: Type8.Optional(Type8.Number({ minimum: 0 })), completion: Type8.Literal("incomplete"), degradationReason: Type8.Optional(nonblank) }, { additionalProperties: false })
2355
2434
  ])),
2356
- outputBytes: Type6.Object({ count: Type6.Integer({ minimum: 0 }), sources: Type6.Array(nonblank), payload: Type6.Literal("raw JSONL bytes"), providerWireBytes: Type6.Literal("unavailable") }, { additionalProperties: false })
2435
+ outputBytes: Type8.Object({ count: Type8.Integer({ minimum: 0 }), sources: Type8.Array(nonblank), payload: Type8.Literal("raw JSONL bytes"), providerWireBytes: Type8.Literal("unavailable") }, { additionalProperties: false })
2357
2436
  }, { additionalProperties: false });
2358
- var doctorSubmissionVariants = Type6.Union([
2359
- Type6.Object({
2360
- status: Type6.Literal("completed", { description: "completed \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8\uFF1B\u5141\u8BB8\u7A7A findings\uFF1Bruntime \u8865\u8BB0\u6D3E\u751F\u6210\u672C\u5165\u56DE\u6267" }),
2361
- case: Type6.Unsafe({ ...caseIdentity, description: "\u7559\u5B58\u592A\u533B\u7F72\u6848\u8EAB\u4EFD" }),
2362
- findings: Type6.Array(finding, { description: "\u53EF\u7A7A\u6216\u4EC5\u542B\u975E\u5904\u65B9\u6848\u89C2\u5BDF\uFF1B\u7F3A\u53EF\u590D\u7528\u8D44\u4EA7\u6216 bounded-bite \u8BC1\u636E\u53EA\u6392\u9664\u5BF9\u5E94\u8D44\u4EA7\u5904\u65B9" })
2437
+ var doctorSubmissionVariants = Type8.Union([
2438
+ Type8.Object({
2439
+ status: Type8.Literal("completed", { description: "completed \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8\uFF1B\u5141\u8BB8\u7A7A findings\uFF1Bruntime \u8865\u8BB0\u6D3E\u751F\u6210\u672C\u5165\u56DE\u6267" }),
2440
+ case: Type8.Unsafe({ ...caseIdentity, description: "\u7559\u5B58\u592A\u533B\u7F72\u6848\u8EAB\u4EFD" }),
2441
+ findings: Type8.Array(finding, { description: "\u53EF\u7A7A\u6216\u4EC5\u542B\u975E\u5904\u65B9\u6848\u89C2\u5BDF\uFF1B\u7F3A\u53EF\u590D\u7528\u8D44\u4EA7\u6216 bounded-bite \u8BC1\u636E\u53EA\u6392\u9664\u5BF9\u5E94\u8D44\u4EA7\u5904\u65B9" })
2363
2442
  }, { additionalProperties: false, description: "\u5355\u6848\u8BC1\u8BCD\uFF0C\u4E0D\u8981\u6C42\u4EFB\u4F55\u5904\u65B9\u6216\u53EF\u590D\u7528 finding" }),
2364
- Type6.Object({
2365
- status: Type6.Literal("refused", { description: "refused \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8\uFF1B\u4EC5\u5F53\u8BC1\u636E\u4E0D\u8DB3\u4EE5\u652F\u6491\u5982\u5B9E\u6848\u8BC1\u8BCD" }),
2366
- reason: Type6.String({ minLength: 1, description: "\u8BC1\u636E\u4E0D\u8DB3\u4EE5\u652F\u6491\u5982\u5B9E\u8BC1\u8BCD\u7684\u539F\u56E0" }),
2367
- missingEvidence: Type6.Array(Type6.Object({ need: nonblank, targetKeys: Type6.Array(nonblank, { minItems: 1 }) }, { additionalProperties: false }), { minItems: 1, description: "\u5982\u5B9E\u8BC1\u8BCD\u6240\u9700\u800C\u5C1A\u7F3A\u7684\u8BC1\u636E" })
2443
+ Type8.Object({
2444
+ status: Type8.Literal("refused", { description: "refused \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8\uFF1B\u4EC5\u5F53\u8BC1\u636E\u4E0D\u8DB3\u4EE5\u652F\u6491\u5982\u5B9E\u6848\u8BC1\u8BCD" }),
2445
+ reason: Type8.String({ minLength: 1, description: "\u8BC1\u636E\u4E0D\u8DB3\u4EE5\u652F\u6491\u5982\u5B9E\u8BC1\u8BCD\u7684\u539F\u56E0" }),
2446
+ missingEvidence: Type8.Array(Type8.Object({ need: nonblank, targetKeys: Type8.Array(nonblank, { minItems: 1 }) }, { additionalProperties: false }), { minItems: 1, description: "\u5982\u5B9E\u8BC1\u8BCD\u6240\u9700\u800C\u5C1A\u7F3A\u7684\u8BC1\u636E" })
2368
2447
  }, { additionalProperties: false, description: "\u8BC1\u636E\u4E0D\u8DB3\u4EE5\u652F\u6491\u5982\u5B9E\u6848\u8BC1\u8BCD" })
2369
2448
  ]);
2370
2449
  var doctorSubmissionSchema = withInfrastructureFailureDeclaration(
2371
2450
  openToolObjectFromUnion(doctorSubmissionVariants)
2372
2451
  );
2373
- var doctorOutputSchema = Type6.Union([
2374
- Type6.Object({ status: Type6.Literal("completed"), case: caseIdentity, findings: Type6.Array(finding), cost }, { additionalProperties: false }),
2452
+ var doctorOutputSchema = Type8.Union([
2453
+ Type8.Object({ status: Type8.Literal("completed"), case: caseIdentity, findings: Type8.Array(finding), cost }, { additionalProperties: false }),
2375
2454
  doctorSubmissionVariants.anyOf[1]
2376
2455
  ]);
2377
- var doctorEvidenceReadSchema = Type6.Object({ evidenceId: Type6.String({ minLength: 1, description: "\u5F85\u8BFB\u7559\u5B58\u8BC1\u636E\u6807\u8BC6" }), offset: Type6.Optional(Type6.Integer({ minimum: 0, description: "\u8D77\u59CB\u5B57\u8282\u504F\u79FB\uFF08\u4ECE 0 \u8BA1\uFF09" })), limit: Type6.Optional(Type6.Integer({ minimum: 1, maximum: 4096, description: "\u8FD4\u56DE\u5B57\u8282\u4E0A\u9650" })) }, { additionalProperties: false });
2456
+ var doctorEvidenceReadSchema = Type8.Object({ evidenceId: Type8.String({ minLength: 1, description: "\u5F85\u8BFB\u7559\u5B58\u8BC1\u636E\u6807\u8BC6" }), offset: Type8.Optional(Type8.Integer({ minimum: 0, description: "\u8D77\u59CB\u5B57\u8282\u504F\u79FB\uFF08\u4ECE 0 \u8BA1\uFF09" })), limit: Type8.Optional(Type8.Integer({ minimum: 1, maximum: 4096, description: "\u8FD4\u56DE\u5B57\u8282\u4E0A\u9650" })) }, { additionalProperties: false });
2378
2457
  var DoctorSubmissionContractError = class extends Error {
2379
2458
  name = "DoctorSubmissionContractError";
2380
2459
  };
2381
- function isRecord3(value) {
2460
+ function isRecord5(value) {
2382
2461
  return typeof value === "object" && value !== null && !Array.isArray(value);
2383
2462
  }
2384
2463
  function read2(value, key) {
2385
- if (!isRecord3(value)) return void 0;
2464
+ if (!isRecord5(value)) return void 0;
2386
2465
  try {
2387
2466
  return value[key];
2388
2467
  } catch {
@@ -2461,7 +2540,7 @@ function validateDoctorOutput(value, patient, store) {
2461
2540
  const targetKey = read2(finding2, "targetKey");
2462
2541
  readCitations(read2(finding2, "evidenceIds"), "finding");
2463
2542
  const assetEvidence = read2(finding2, "assetEvidence");
2464
- if (!isRecord3(assetEvidence)) {
2543
+ if (!isRecord5(assetEvidence)) {
2465
2544
  assertTarget(targetKey);
2466
2545
  continue;
2467
2546
  }
@@ -2495,7 +2574,7 @@ function validateDoctorOutput(value, patient, store) {
2495
2574
  }
2496
2575
 
2497
2576
  // src/merger-contracts.ts
2498
- import { Type as Type7 } from "typebox";
2577
+ import { Type as Type9 } from "typebox";
2499
2578
 
2500
2579
  // src/git-object-id.ts
2501
2580
  var FULL_GIT_OBJECT_ID_RE = /^(?:[0-9a-f]{40}|[0-9a-f]{64})$/;
@@ -2523,21 +2602,21 @@ function sha256Hex(bytes) {
2523
2602
 
2524
2603
  // src/merger-contracts.ts
2525
2604
  var oidPattern = "^(?:[0-9a-f]{40}|[0-9a-f]{64})$";
2526
- var materialSchema = Type7.Object({ bytesBase64: Type7.String(), sha256: Type7.String() }, { additionalProperties: false });
2527
- var checkSchema = Type7.Object({ name: Type7.String({ minLength: 1 }), argv: Type7.Array(Type7.String({ minLength: 1 }), { minItems: 1 }) }, { additionalProperties: false });
2528
- var mergerInputSchema = Type7.Object({
2529
- version: Type7.Literal(1),
2530
- attemptId: Type7.String({ minLength: 1 }),
2531
- targetObjectId: Type7.String({ pattern: oidPattern }),
2532
- sourceObjectId: Type7.String({ pattern: oidPattern }),
2533
- materials: Type7.Object({ task: materialSchema, authority: materialSchema, targetIntent: materialSchema, sourceIntent: materialSchema }, { additionalProperties: false }),
2534
- expectedConflictPaths: Type7.Array(Type7.String({ minLength: 1 }), { minItems: 1 }),
2535
- resolutionScope: Type7.Array(Type7.String({ minLength: 1 }), { minItems: 1 }),
2536
- authorizedChecks: Type7.Array(checkSchema)
2605
+ var materialSchema = Type9.Object({ bytesBase64: Type9.String(), sha256: Type9.String() }, { additionalProperties: false });
2606
+ var checkSchema = Type9.Object({ name: Type9.String({ minLength: 1 }), argv: Type9.Array(Type9.String({ minLength: 1 }), { minItems: 1 }) }, { additionalProperties: false });
2607
+ var mergerInputSchema = Type9.Object({
2608
+ version: Type9.Literal(1),
2609
+ attemptId: Type9.String({ minLength: 1 }),
2610
+ targetObjectId: Type9.String({ pattern: oidPattern }),
2611
+ sourceObjectId: Type9.String({ pattern: oidPattern }),
2612
+ materials: Type9.Object({ task: materialSchema, authority: materialSchema, targetIntent: materialSchema, sourceIntent: materialSchema }, { additionalProperties: false }),
2613
+ expectedConflictPaths: Type9.Array(Type9.String({ minLength: 1 }), { minItems: 1 }),
2614
+ resolutionScope: Type9.Array(Type9.String({ minLength: 1 }), { minItems: 1 }),
2615
+ authorizedChecks: Type9.Array(checkSchema)
2537
2616
  }, { additionalProperties: false });
2538
- var mergerOutputVariants = Type7.Union([
2539
- Type7.Object({ status: Type7.Literal("completed", { description: "completed \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8" }), attemptId: Type7.String({ minLength: 1, description: "\u5DF2\u53D7\u7406\u5408\u5E76 attempt \u8EAB\u4EFD" }), report: Type7.String({ minLength: 1, description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }), mergeCommitId: Type7.String({ pattern: oidPattern, description: "\u5DF2\u6838\u9A8C\u7684\u5B8C\u6210\u5408\u5E76 commit object ID" }) }, { additionalProperties: false }),
2540
- Type7.Object({ status: Type7.Literal("escalate", { description: "escalate \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8" }), attemptId: Type7.String({ minLength: 1, description: "\u5DF2\u53D7\u7406\u5408\u5E76 attempt \u8EAB\u4EFD" }), diagnosis: Type7.String({ minLength: 1, description: "\u5408\u5E76\u5B8C\u6210\u9700\u5347\u7EA7\u7684\u539F\u56E0" }), report: Type7.String({ minLength: 1, description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }) }, { additionalProperties: false })
2617
+ var mergerOutputVariants = Type9.Union([
2618
+ Type9.Object({ status: Type9.Literal("completed", { description: "completed \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8" }), attemptId: Type9.String({ minLength: 1, description: "\u5DF2\u53D7\u7406\u5408\u5E76 attempt \u8EAB\u4EFD" }), report: Type9.String({ minLength: 1, description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }), mergeCommitId: Type9.String({ pattern: oidPattern, description: "\u5DF2\u6838\u9A8C\u7684\u5B8C\u6210\u5408\u5E76 commit object ID" }) }, { additionalProperties: false }),
2619
+ Type9.Object({ status: Type9.Literal("escalate", { description: "escalate \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8" }), attemptId: Type9.String({ minLength: 1, description: "\u5DF2\u53D7\u7406\u5408\u5E76 attempt \u8EAB\u4EFD" }), diagnosis: Type9.String({ minLength: 1, description: "\u5408\u5E76\u5B8C\u6210\u9700\u5347\u7EA7\u7684\u539F\u56E0" }), report: Type9.String({ minLength: 1, description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }) }, { additionalProperties: false })
2541
2620
  ]);
2542
2621
  var mergerOutputSchema = withInfrastructureFailureDeclaration(
2543
2622
  openToolObjectFromUnion(mergerOutputVariants)
@@ -2597,7 +2676,7 @@ function validateMergerOutput(value, expectedAttemptId) {
2597
2676
  }
2598
2677
 
2599
2678
  // src/notary-contracts.ts
2600
- import { Type as Type8 } from "typebox";
2679
+ import { Type as Type10 } from "typebox";
2601
2680
  var NOTARY_OUTPUT_TOOL_NAME = "ak_notary_output";
2602
2681
  var NOTARY_ACCEPTED_TEXT = "\u7B26\u5B9D\u90CE\u56DE\u6267\u5DF2\u63A5\u53D7";
2603
2682
  var NOTARY_SOURCE_RUN_FLAG = {
@@ -2616,35 +2695,35 @@ var NOTARY_TICKET_FLAG = {
2616
2695
  };
2617
2696
  var notaryOutputSchema = withInfrastructureFailureDeclaration(
2618
2697
  openToolObject(
2619
- Type8.Object({
2620
- status: Type8.Unknown({
2698
+ Type10.Object({
2699
+ status: Type10.Unknown({
2621
2700
  description: "pass | bounce \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8"
2622
2701
  }),
2623
- findings: Type8.Unknown({
2702
+ findings: Type10.Unknown({
2624
2703
  description: "string[] findings\uFF0C\u968F pass \u6216 bounce \u7559\u5B58"
2625
2704
  })
2626
2705
  })
2627
2706
  )
2628
2707
  );
2629
- function isRecord4(value) {
2708
+ function isRecord6(value) {
2630
2709
  return typeof value === "object" && value !== null && !Array.isArray(value);
2631
2710
  }
2632
- function asStringArray(value) {
2711
+ function asStringArray2(value) {
2633
2712
  if (!Array.isArray(value)) return [];
2634
2713
  return value.filter((item) => typeof item === "string");
2635
2714
  }
2636
2715
  function projectLawfulNotaryOutput(value) {
2637
- if (!isRecord4(value)) return void 0;
2716
+ if (!isRecord6(value)) return void 0;
2638
2717
  const status = typeof value.status === "string" ? value.status : void 0;
2639
2718
  if (status === "bounce") {
2640
2719
  const clone = structuredClone(value);
2641
2720
  if (clone.disposition === void 0) clone.disposition = "rewrite";
2642
- if (!Array.isArray(clone.findings)) clone.findings = asStringArray(clone.findings);
2721
+ if (!Array.isArray(clone.findings)) clone.findings = asStringArray2(clone.findings);
2643
2722
  return clone;
2644
2723
  }
2645
2724
  if (status === "pass") {
2646
2725
  const clone = structuredClone(value);
2647
- if (!Array.isArray(clone.findings)) clone.findings = asStringArray(clone.findings);
2726
+ if (!Array.isArray(clone.findings)) clone.findings = asStringArray2(clone.findings);
2648
2727
  return clone;
2649
2728
  }
2650
2729
  return void 0;
@@ -2876,6 +2955,28 @@ var PUBLIC_ROLE_RECORDS = [
2876
2955
  phaseFlag: void 0,
2877
2956
  activationStage: "load-and-install",
2878
2957
  sessionMaterials: INSPECTOR_SESSION_MATERIALS
2958
+ },
2959
+ // #639: gatekeeper and navigator are roles like any other — public ak-role
2960
+ // entries; automatic attendance (province dispatch, navigator sidecar) is
2961
+ // unchanged and orthogonal to callability.
2962
+ {
2963
+ role: "gatekeeper",
2964
+ phases: [null],
2965
+ outputTool: GATEKEEPER_OUTPUT_TOOL_NAME,
2966
+ inputFlag: void 0,
2967
+ phaseFlag: void 0,
2968
+ activationStage: "load-and-install",
2969
+ // Province materials; officers reuse their own public records below.
2970
+ sessionMaterials: ["CLAUDE.md", "souls/gatekeeper.md", "souls/quality-law.md", "souls/gate-output-guide.md"]
2971
+ },
2972
+ {
2973
+ role: "navigator",
2974
+ phases: [null],
2975
+ outputTool: NAVIGATOR_OUTPUT_TOOL_NAME,
2976
+ inputFlag: void 0,
2977
+ phaseFlag: void 0,
2978
+ activationStage: "load-and-install",
2979
+ sessionMaterials: ["CLAUDE.md", "souls/navigator.md"]
2879
2980
  }
2880
2981
  ];
2881
2982
  var PACKAGED_ROLE_REGISTRY = PUBLIC_ROLE_RECORDS.map(({ sessionMaterials: _omit, ...metadata }) => metadata);
@@ -2919,19 +3020,14 @@ async function joinPackageMaterials(relativePaths) {
2919
3020
  var MAIN_ROLE_SESSION_MATERIALS = {
2920
3021
  ...Object.fromEntries(
2921
3022
  PUBLIC_ROLE_RECORDS.map((record4) => [record4.role, record4.sessionMaterials])
2922
- ),
2923
- navigator: ["CLAUDE.md", "souls/navigator.md"]
3023
+ )
2924
3024
  };
2925
3025
  function loadMainRoleSessionMaterials(role) {
2926
3026
  return joinPackageMaterials(MAIN_ROLE_SESSION_MATERIALS[role]);
2927
3027
  }
2928
3028
  var GATEKEEPER_SESSION_MATERIALS = {
2929
- gatekeeper: [
2930
- "CLAUDE.md",
2931
- "souls/gatekeeper.md",
2932
- "souls/quality-law.md",
2933
- "souls/gate-output-guide.md"
2934
- ],
3029
+ // #639: single authority — the public gatekeeper record owns the province list.
3030
+ gatekeeper: PUBLIC_ROLE_RECORDS.find((entry) => entry.role === "gatekeeper").sessionMaterials,
2935
3031
  inspector: INSPECTOR_SESSION_MATERIALS,
2936
3032
  notary: NOTARY_SESSION_MATERIALS
2937
3033
  };
@@ -2963,7 +3059,7 @@ async function loadAuditorSoul(role) {
2963
3059
  }
2964
3060
 
2965
3061
  // src/compliance-transport.ts
2966
- import { Type as Type11 } from "typebox";
3062
+ import { Type as Type13 } from "typebox";
2967
3063
 
2968
3064
  // src/evidence-child-executor.ts
2969
3065
  import { mkdtemp as mkdtemp3, rm as rm3 } from "node:fs/promises";
@@ -3000,7 +3096,7 @@ var SitianInfrastructureError = class extends Error {
3000
3096
  };
3001
3097
 
3002
3098
  // src/sitian-appender.ts
3003
- function isRecord5(value) {
3099
+ function isRecord7(value) {
3004
3100
  return typeof value === "object" && value !== null && !Array.isArray(value);
3005
3101
  }
3006
3102
  function errorCodeOf(error) {
@@ -3028,7 +3124,7 @@ function findIdentityPointer(recordFile, identity, kind, level) {
3028
3124
  if (!trimmed) continue;
3029
3125
  try {
3030
3126
  const parsed = JSON.parse(trimmed);
3031
- if (isRecord5(parsed) && parsed.identity === identity) {
3127
+ if (isRecord7(parsed) && parsed.identity === identity) {
3032
3128
  return { identity, recordFile, kind, level };
3033
3129
  }
3034
3130
  } catch {
@@ -3207,7 +3303,7 @@ function appendSitianRecord(input) {
3207
3303
  // src/sitian-reader.ts
3208
3304
  import { existsSync as existsSync3 } from "node:fs";
3209
3305
  import { readFile as readFile3 } from "node:fs/promises";
3210
- function isRecord6(value) {
3306
+ function isRecord8(value) {
3211
3307
  return typeof value === "object" && value !== null && !Array.isArray(value);
3212
3308
  }
3213
3309
  async function readSitianRecords(recordFile) {
@@ -3223,7 +3319,7 @@ async function readSitianRecords(recordFile) {
3223
3319
  if (!line2.trim()) continue;
3224
3320
  try {
3225
3321
  const parsed = JSON.parse(line2);
3226
- if (isRecord6(parsed)) {
3322
+ if (isRecord8(parsed)) {
3227
3323
  records2.push(parsed);
3228
3324
  } else {
3229
3325
  const typeDesc = parsed === null ? "null" : Array.isArray(parsed) ? "array" : typeof parsed;
@@ -3252,7 +3348,7 @@ function sitianReport(input) {
3252
3348
  }
3253
3349
 
3254
3350
  // src/engine-detour-tool.ts
3255
- import { Type as Type9 } from "typebox";
3351
+ import { Type as Type11 } from "typebox";
3256
3352
 
3257
3353
  // src/engine-detour.ts
3258
3354
  import { spawn as spawn2 } from "node:child_process";
@@ -3405,9 +3501,9 @@ function engineNameFromEnv() {
3405
3501
  }
3406
3502
 
3407
3503
  // src/engine-detour-tool.ts
3408
- var engineDetourArgsSchema = Type9.Object(
3504
+ var engineDetourArgsSchema = Type11.Object(
3409
3505
  {
3410
- argv: Type9.Array(Type9.String({ minLength: 1 }), {
3506
+ argv: Type11.Array(Type11.String({ minLength: 1 }), {
3411
3507
  minItems: 1,
3412
3508
  description: "\u9996\u9879\u4E3A PATH \u4E2D\u7684\u53EF\u6267\u884C\u6587\u4EF6\uFF0C\u5176\u4F59\u9879\u4E3A\u53C2\u6570\u3002"
3413
3509
  })
@@ -3544,15 +3640,8 @@ import { join as join7 } from "node:path";
3544
3640
  var PUBLIC_CALLABLE_ROLES = PACKAGED_ROLE_REGISTRY.map(
3545
3641
  (entry) => entry.role
3546
3642
  );
3547
- var AUTOMATIC_NAVIGATOR_SEAT = "navigator";
3548
- var AUTOMATIC_GATEKEEPER_SEAT = "gatekeeper";
3549
- var AUTOMATIC_CONFIGURABLE_SEATS = [
3550
- AUTOMATIC_GATEKEEPER_SEAT,
3551
- AUTOMATIC_NAVIGATOR_SEAT
3552
- ];
3553
3643
  var PUBLIC_CONFIGURABLE_SEATS = [
3554
- ...PUBLIC_CALLABLE_ROLES,
3555
- ...AUTOMATIC_CONFIGURABLE_SEATS
3644
+ ...PUBLIC_CALLABLE_ROLES
3556
3645
  ];
3557
3646
 
3558
3647
  // src/institutional-resolution.ts
@@ -3623,7 +3712,7 @@ async function readInstitutionalSeatSelection(runDirectory, seat) {
3623
3712
  import { mkdir, readFile as readFile5, writeFile as writeFile3 } from "node:fs/promises";
3624
3713
  import { homedir as homedir2 } from "node:os";
3625
3714
  import { dirname as dirname7, join as join8 } from "node:path";
3626
- import { Type as Type10 } from "typebox";
3715
+ import { Type as Type12 } from "typebox";
3627
3716
  import { Value as Value2 } from "typebox/value";
3628
3717
  var NAVIGATOR_PREPARE_TOOL_NAME = "ak_navigator_prepare";
3629
3718
  var NAVIGATOR_DEFAULT_MODEL = "openai-codex/gpt-5.6-luna:max";
@@ -3714,26 +3803,26 @@ function navigatorProviderFailureFromDiagnostics(diagnostics) {
3714
3803
  }
3715
3804
  return void 0;
3716
3805
  }
3717
- var navigatorProviderFailureSchema = Type10.Object({
3718
- source: Type10.Union([
3719
- Type10.Literal("context"),
3720
- Type10.Literal("session"),
3721
- Type10.Literal("model"),
3722
- Type10.Literal("thinking"),
3723
- Type10.Literal("auth"),
3724
- Type10.Literal("quota"),
3725
- Type10.Literal("transport"),
3726
- Type10.Literal("unknown")
3806
+ var navigatorProviderFailureSchema = Type12.Object({
3807
+ source: Type12.Union([
3808
+ Type12.Literal("context"),
3809
+ Type12.Literal("session"),
3810
+ Type12.Literal("model"),
3811
+ Type12.Literal("thinking"),
3812
+ Type12.Literal("auth"),
3813
+ Type12.Literal("quota"),
3814
+ Type12.Literal("transport"),
3815
+ Type12.Literal("unknown")
3727
3816
  ]),
3728
- cause: Type10.Union([
3729
- Type10.Literal("context"),
3730
- Type10.Literal("session"),
3731
- Type10.Literal("model"),
3732
- Type10.Literal("thinking"),
3733
- Type10.Literal("auth"),
3734
- Type10.Literal("quota"),
3735
- Type10.Literal("transport"),
3736
- Type10.Literal("unknown")
3817
+ cause: Type12.Union([
3818
+ Type12.Literal("context"),
3819
+ Type12.Literal("session"),
3820
+ Type12.Literal("model"),
3821
+ Type12.Literal("thinking"),
3822
+ Type12.Literal("auth"),
3823
+ Type12.Literal("quota"),
3824
+ Type12.Literal("transport"),
3825
+ Type12.Literal("unknown")
3737
3826
  ])
3738
3827
  }, { additionalProperties: false });
3739
3828
  function navigatorModelSettingPath() {
@@ -4696,9 +4785,9 @@ var ComplianceCandidateUnreadableError = class extends Error {
4696
4785
  }
4697
4786
  };
4698
4787
  var AUDITOR_DOSSIER_PROMPT = "\u672C run \u5377\u5B97\u5DF2\u5C31\u7EEA\u3002";
4699
- var nonblank2 = Type11.String({ minLength: 1, pattern: "\\S" });
4700
- var decisionGateSchema = Type11.Object({ question: nonblank2, options: Type11.Array(nonblank2, { minItems: 1 }) }, { additionalProperties: false });
4701
- var complianceDecisionSchema = Type11.Object({ status: Type11.Unknown({ description: "pass | revise | escalate \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8" }), violations: Type11.Array(nonblank2, { description: "\u89C2\u5BDF\u5230\u7684\u5408\u89C4\u8FDD\u89C4" }), conflicts: Type11.Array(nonblank2, { description: "\u672A\u51B3\u6743\u5A01\u6216\u6267\u884C\u51B2\u7A81" }), decisionGate: Type11.Union([decisionGateSchema, Type11.Null()], { description: "\u5347\u7EA7\u95EE\u9898\u4E0E\u53EF\u9009\u9009\u9879" }) }, { additionalProperties: true, required: [] });
4788
+ var nonblank2 = Type13.String({ minLength: 1, pattern: "\\S" });
4789
+ var decisionGateSchema = Type13.Object({ question: nonblank2, options: Type13.Array(nonblank2, { minItems: 1 }) }, { additionalProperties: false });
4790
+ var complianceDecisionSchema = Type13.Object({ status: Type13.Unknown({ description: "pass | revise | escalate \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8" }), violations: Type13.Array(nonblank2, { description: "\u89C2\u5BDF\u5230\u7684\u5408\u89C4\u8FDD\u89C4" }), conflicts: Type13.Array(nonblank2, { description: "\u672A\u51B3\u6743\u5A01\u6216\u6267\u884C\u51B2\u7A81" }), decisionGate: Type13.Union([decisionGateSchema, Type13.Null()], { description: "\u5347\u7EA7\u95EE\u9898\u4E0E\u53EF\u9009\u9009\u9879" }) }, { additionalProperties: true, required: [] });
4702
4791
  function createComplianceDecisionTool(name, description) {
4703
4792
  return { name, description, parameters: complianceDecisionSchema, async execute(_id, params) {
4704
4793
  return { content: [{ type: "text", text: "\u5BA1\u8BA1\u51B3\u8BAE\u5DF2\u6536" }], details: params, terminate: true };
@@ -4796,7 +4885,7 @@ function resolveAuditDossier(env = process.env) {
4796
4885
  }
4797
4886
  return { status: "ok", runDirectory };
4798
4887
  }
4799
- function isRecord7(value) {
4888
+ function isRecord9(value) {
4800
4889
  return typeof value === "object" && value !== null && !Array.isArray(value);
4801
4890
  }
4802
4891
  function readJudgeAuditSubjects(context) {
@@ -4804,15 +4893,15 @@ function readJudgeAuditSubjects(context) {
4804
4893
  let hasAssignment = false;
4805
4894
  let hasCandidate = false;
4806
4895
  for (const entry of entries) {
4807
- if (!isRecord7(entry) || entry.type !== "message" || !isRecord7(entry.message)) continue;
4896
+ if (!isRecord9(entry) || entry.type !== "message" || !isRecord9(entry.message)) continue;
4808
4897
  const message = entry.message;
4809
4898
  if (message.role === "user") {
4810
- const text = typeof message.content === "string" ? message.content : Array.isArray(message.content) ? message.content.map((part) => isRecord7(part) && part.type === "text" && typeof part.text === "string" ? part.text : "").join("") : "";
4899
+ const text = typeof message.content === "string" ? message.content : Array.isArray(message.content) ? message.content.map((part) => isRecord9(part) && part.type === "text" && typeof part.text === "string" ? part.text : "").join("") : "";
4811
4900
  if (text.trim().length > 0) hasAssignment = true;
4812
4901
  }
4813
4902
  if (message.role === "assistant" && Array.isArray(message.content)) {
4814
4903
  for (const part of message.content) {
4815
- if (isRecord7(part) && part.type === "toolCall" && part.name === JUDGE_OUTPUT_TOOL_NAME2 && isRecord7(part.arguments)) {
4904
+ if (isRecord9(part) && part.type === "toolCall" && part.name === JUDGE_OUTPUT_TOOL_NAME2 && isRecord9(part.arguments)) {
4816
4905
  hasCandidate = true;
4817
4906
  }
4818
4907
  }
@@ -4829,7 +4918,7 @@ function readJudgeAuditSubjects(context) {
4829
4918
  function readDoctorAuditSubjects(context) {
4830
4919
  const entries = context.sessionManager.getEntries?.() ?? [];
4831
4920
  for (const entry of entries) {
4832
- if (isRecord7(entry) && entry.type === "custom" && entry.customType === DOCTOR_CANDIDATE_ENTRY_TYPE) {
4921
+ if (isRecord9(entry) && entry.type === "custom" && entry.customType === DOCTOR_CANDIDATE_ENTRY_TYPE) {
4833
4922
  return { status: "ok" };
4834
4923
  }
4835
4924
  }
@@ -5020,7 +5109,9 @@ var TERMINATING_TOOL_NAMES = [
5020
5109
  NOTARY_OUTPUT_TOOL_NAME,
5021
5110
  COUNTERSIGN_OUTPUT_TOOL_NAME,
5022
5111
  GLEANER_LEFT_OUTPUT_TOOL_NAME,
5023
- INSPECTOR_OUTPUT_TOOL_NAME
5112
+ INSPECTOR_OUTPUT_TOOL_NAME,
5113
+ GATEKEEPER_OUTPUT_TOOL_NAME,
5114
+ NAVIGATOR_OUTPUT_TOOL_NAME
5024
5115
  ];
5025
5116
  function isTerminatingToolName(name) {
5026
5117
  return TERMINATING_TOOL_NAMES.includes(name);
@@ -5064,7 +5155,9 @@ function validateAcceptedDetails(toolName, details) {
5064
5155
  [NOTARY_OUTPUT_TOOL_NAME]: ["pass", "bounce"],
5065
5156
  [COUNTERSIGN_OUTPUT_TOOL_NAME]: ["converged", "continue", "escalate"],
5066
5157
  [GLEANER_LEFT_OUTPUT_TOOL_NAME]: ["completed"],
5067
- [INSPECTOR_OUTPUT_TOOL_NAME]: ["pass", "bounce"]
5158
+ [INSPECTOR_OUTPUT_TOOL_NAME]: ["pass", "bounce"],
5159
+ [GATEKEEPER_OUTPUT_TOOL_NAME]: ["dispatch", "pass"],
5160
+ [NAVIGATOR_OUTPUT_TOOL_NAME]: ["advice"]
5068
5161
  };
5069
5162
  const collectorDiscriminator = toolName === COLLECTOR_OUTPUT_TOOL && Array.isArray(candidate?.groups);
5070
5163
  const baseDiscriminator = discriminator;
@@ -5096,6 +5189,10 @@ function validateAcceptedDetails(toolName, details) {
5096
5189
  return validateRecordedGleanerLeftOutput(details);
5097
5190
  case INSPECTOR_OUTPUT_TOOL_NAME:
5098
5191
  return validateRecordedInspectorOutput(details);
5192
+ case GATEKEEPER_OUTPUT_TOOL_NAME:
5193
+ return validateRecordedGatekeeperOutput(details);
5194
+ case NAVIGATOR_OUTPUT_TOOL_NAME:
5195
+ return validateRecordedNavigatorOutput(details);
5099
5196
  }
5100
5197
  } catch (error) {
5101
5198
  if (error instanceof Error && error.constructor === Error) throw new AcceptedDetailsContractError(error.message, { cause: error });
@@ -5111,6 +5208,8 @@ function acceptedFacts(toolName, details) {
5111
5208
  case NOTARY_OUTPUT_TOOL_NAME:
5112
5209
  case GLEANER_LEFT_OUTPUT_TOOL_NAME:
5113
5210
  case INSPECTOR_OUTPUT_TOOL_NAME:
5211
+ case GATEKEEPER_OUTPUT_TOOL_NAME:
5212
+ case NAVIGATOR_OUTPUT_TOOL_NAME:
5114
5213
  return { status: details.status };
5115
5214
  case JUDGE_OUTPUT_TOOL_NAME:
5116
5215
  return { status: details.judgeStatus };
@@ -5362,7 +5461,7 @@ function createProductionMergerGitState(repositoryRoot = process.cwd()) {
5362
5461
  import { createHash as createHash5 } from "node:crypto";
5363
5462
  import { resolve as resolve10 } from "node:path";
5364
5463
  import "@earendil-works/pi-coding-agent";
5365
- import { Type as Type12 } from "typebox";
5464
+ import { Type as Type14 } from "typebox";
5366
5465
 
5367
5466
  // src/uuidv7.ts
5368
5467
  import { randomBytes } from "node:crypto";
@@ -5575,11 +5674,11 @@ function resolveLifecycleInvocationPrincipal(entries, expected) {
5575
5674
  init_activation_ledger_topology();
5576
5675
 
5577
5676
  // src/public-command-renderer.ts
5578
- var PUBLIC_CALLABLE_ROLES2 = new Set(
5677
+ var PUBLIC_CALLABLE_ROLES3 = new Set(
5579
5678
  PACKAGED_ROLE_REGISTRY.map((entry) => entry.role)
5580
5679
  );
5581
5680
  function isPublicCallableRole2(role) {
5582
- return PUBLIC_CALLABLE_ROLES2.has(role);
5681
+ return PUBLIC_CALLABLE_ROLES3.has(role);
5583
5682
  }
5584
5683
  function renderPublicAkRoleCommand(target) {
5585
5684
  if (!isPublicCallableRole2(target.role)) return void 0;
@@ -5606,8 +5705,8 @@ function resolveNavigatorAuthorityMaterial(roleInput, fileAuthority) {
5606
5705
  return void 0;
5607
5706
  }
5608
5707
  var NAVIGATOR_TARGETS = PACKAGED_ROLE_REGISTRY.map(({ role, phases }) => ({ role, phases }));
5609
- var prepareSchema = Type12.Object({
5610
- candidates: Type12.Optional(Type12.Unknown({
5708
+ var prepareSchema = Type14.Object({
5709
+ candidates: Type14.Optional(Type14.Unknown({
5611
5710
  description: "\u65B9\u5411\u5019\u9009\uFF1Bcandidates[].next.role \u5FC5\u586B\uFF0Cphase \u53EF\u9009\uFF0Croute/matches/reason/command \u53EF\u9009\u4E0A\u4E0B\u6587\uFF0C\u975E\u53D7\u7406\u95F8"
5612
5711
  }))
5613
5712
  }, { additionalProperties: true });
@@ -6413,6 +6512,14 @@ var INSPECTOR_OPTIONS = [
6413
6512
  bindOwner("inspector", SHARED_PROJECT_SEMANTICS),
6414
6513
  bindOwner("inspector", SHARED_ATTACH_SEMANTICS)
6415
6514
  ];
6515
+ var GATEKEEPER_OPTIONS = [
6516
+ bindOwner("gatekeeper", SHARED_PROJECT_SEMANTICS),
6517
+ bindOwner("gatekeeper", SHARED_ATTACH_SEMANTICS)
6518
+ ];
6519
+ var NAVIGATOR_OPTIONS = [
6520
+ bindOwner("navigator", SHARED_PROJECT_SEMANTICS),
6521
+ bindOwner("navigator", SHARED_ATTACH_SEMANTICS)
6522
+ ];
6416
6523
  var COUNTERSIGN_OPTIONS = [
6417
6524
  bindOwner("countersign", SHARED_PROJECT_SEMANTICS),
6418
6525
  bindOwner("countersign", SHARED_ATTACH_SEMANTICS),
@@ -6743,6 +6850,22 @@ var ROLE_COMMAND_HELP = {
6743
6850
  'ak-role inspector --attach ./change.patch "Review this material."'
6744
6851
  ]
6745
6852
  },
6853
+ gatekeeper: {
6854
+ command: "gatekeeper",
6855
+ summary: "Direct Gatekeeper (\u95E8\u4E0B\u7701) review: dispatch an officer or pass.",
6856
+ usage: ["ak-role gatekeeper [options] [instruction]"],
6857
+ examples: [
6858
+ 'ak-role gatekeeper --attach ./submission.json "\u5BA1\uFF1A\u8FD9\u6279\u6750\u6599\u8BE5\u8C01\u5BA1\uFF1F"'
6859
+ ]
6860
+ },
6861
+ navigator: {
6862
+ command: "navigator",
6863
+ summary: "Direct Navigator (\u6E38\u5955\u4F7F) route advice: ordered next-role candidates.",
6864
+ usage: ["ak-role navigator [options] [instruction]"],
6865
+ examples: [
6866
+ 'ak-role navigator "\u521A\u5B8C\u6210 coder apply \u6536\u655B\uFF0C\u4E0B\u4E00\u6B65\uFF1F"'
6867
+ ]
6868
+ },
6746
6869
  notary: {
6747
6870
  command: "notary",
6748
6871
  summary: "Direct Notary document check (quote fidelity + ticket alignment); zero prompt/attachment.",
@@ -6860,7 +6983,7 @@ async function readRoleRunStateDisk(runDirectory) {
6860
6983
  if (typeof record4.runId !== "string" || record4.runId.trim() === "") {
6861
6984
  return void 0;
6862
6985
  }
6863
- if (record4.role !== "judge" && record4.role !== "coder" && record4.role !== "fixer" && record4.role !== "collector" && record4.role !== "doctor" && record4.role !== "reviewer" && record4.role !== "merger" && record4.role !== "notary" && record4.role !== "countersign" && record4.role !== "gleaner-left" && record4.role !== "inspector") {
6986
+ if (record4.role !== "judge" && record4.role !== "coder" && record4.role !== "fixer" && record4.role !== "collector" && record4.role !== "doctor" && record4.role !== "reviewer" && record4.role !== "merger" && record4.role !== "notary" && record4.role !== "countersign" && record4.role !== "gleaner-left" && record4.role !== "inspector" && record4.role !== "gatekeeper" && record4.role !== "navigator") {
6864
6987
  return void 0;
6865
6988
  }
6866
6989
  if (record4.state !== "admitted" && record4.state !== "running" && record4.state !== "resumable" && record4.state !== "terminal") {
@@ -7115,11 +7238,11 @@ function resolvePackagedMethodSkillRoot(packageRoot, name) {
7115
7238
  function resolvePackagedMethodSkillPath(packageRoot, name) {
7116
7239
  return join17(resolvePackagedMethodSkillRoot(packageRoot, name), "SKILL.md");
7117
7240
  }
7118
- function isRecord8(value) {
7241
+ function isRecord10(value) {
7119
7242
  return typeof value === "object" && value !== null && !Array.isArray(value);
7120
7243
  }
7121
7244
  function parseProvenance(raw, expectedName) {
7122
- if (!isRecord8(raw)) {
7245
+ if (!isRecord10(raw)) {
7123
7246
  throw new Error(`Packaged method provenance must be an object for ${expectedName}`);
7124
7247
  }
7125
7248
  if (raw.name !== expectedName) {
@@ -7133,7 +7256,7 @@ function parseProvenance(raw, expectedName) {
7133
7256
  if (typeof raw.packageAdaptation !== "string" || raw.packageAdaptation.trim() === "") {
7134
7257
  throw new Error(`Packaged method provenance packageAdaptation must be nonblank`);
7135
7258
  }
7136
- if (!isRecord8(raw.upstream)) {
7259
+ if (!isRecord10(raw.upstream)) {
7137
7260
  throw new Error(`Packaged method provenance upstream must be an object`);
7138
7261
  }
7139
7262
  const upstream = raw.upstream;
@@ -7160,12 +7283,12 @@ function parseProvenance(raw, expectedName) {
7160
7283
  `Packaged method provenance upstream must include nonblank tag or version`
7161
7284
  );
7162
7285
  }
7163
- if (!isRecord8(raw.files)) {
7286
+ if (!isRecord10(raw.files)) {
7164
7287
  throw new Error(`Packaged method provenance files must be an object`);
7165
7288
  }
7166
7289
  const files = {};
7167
7290
  for (const [rel, entry] of Object.entries(raw.files)) {
7168
- if (!isRecord8(entry)) {
7291
+ if (!isRecord10(entry)) {
7169
7292
  throw new Error(`Packaged method provenance file entry must be an object: ${rel}`);
7170
7293
  }
7171
7294
  if (typeof entry.sha256 !== "string" || !SHA256_RE.test(entry.sha256)) {
@@ -7618,7 +7741,7 @@ import { readFileSync as readFileSync4, writeSync as writeSync4 } from "node:fs"
7618
7741
  import { join as pathJoin } from "node:path";
7619
7742
 
7620
7743
  // src/host-contracts.ts
7621
- import { Type as Type13 } from "typebox";
7744
+ import { Type as Type15 } from "typebox";
7622
7745
  var ExplicitInternalActivationError = class extends Error {
7623
7746
  knownCause;
7624
7747
  failureCode;
@@ -7635,7 +7758,7 @@ var ExplicitInternalActivationError = class extends Error {
7635
7758
  }
7636
7759
  };
7637
7760
  function stringEnum(values, options = {}) {
7638
- return Type13.Union(values.map((value) => Type13.Literal(value)), options);
7761
+ return Type15.Union(values.map((value) => Type15.Literal(value)), options);
7639
7762
  }
7640
7763
 
7641
7764
  // src/public-cli/reviewer-dispatch-rejection.ts
@@ -8484,18 +8607,18 @@ function createSubmissionLedgerHost(host, outputTools, failInfrastructure2 = (er
8484
8607
  }
8485
8608
 
8486
8609
  // src/activation-trace.ts
8487
- import { Type as Type14 } from "typebox";
8488
- var causeSchema = Type14.Object({
8489
- identity: Type14.String({ minLength: 1 }),
8490
- name: Type14.String({ minLength: 1 }),
8491
- message: Type14.String(),
8492
- evidenceId: Type14.Optional(Type14.String({ minLength: 1 }))
8610
+ import { Type as Type16 } from "typebox";
8611
+ var causeSchema = Type16.Object({
8612
+ identity: Type16.String({ minLength: 1 }),
8613
+ name: Type16.String({ minLength: 1 }),
8614
+ message: Type16.String(),
8615
+ evidenceId: Type16.Optional(Type16.String({ minLength: 1 }))
8493
8616
  }, { additionalProperties: false });
8494
- var activationTraceRecordSchema = Type14.Object({
8495
- role: Type14.String({ minLength: 1 }),
8496
- stageId: Type14.String({ pattern: "^[a-z][a-z0-9-]*$" }),
8497
- status: Type14.Literal("failed"),
8498
- timestamp: Type14.String({ format: "date-time" }),
8617
+ var activationTraceRecordSchema = Type16.Object({
8618
+ role: Type16.String({ minLength: 1 }),
8619
+ stageId: Type16.String({ pattern: "^[a-z][a-z0-9-]*$" }),
8620
+ status: Type16.Literal("failed"),
8621
+ timestamp: Type16.String({ format: "date-time" }),
8499
8622
  cause: causeSchema
8500
8623
  }, { additionalProperties: false });
8501
8624
  var activationCauseEvidence = 0;
@@ -8777,28 +8900,28 @@ function writeStderrJsonlRecord(record4, write = writeSync2) {
8777
8900
 
8778
8901
  // src/tool-execution-observation.ts
8779
8902
  import { writeSync as writeSync3 } from "node:fs";
8780
- import { Type as Type15 } from "typebox";
8903
+ import { Type as Type17 } from "typebox";
8781
8904
  import { Value as Value3 } from "typebox/value";
8782
8905
  var TOOL_EXECUTION_UPDATE_THROTTLE_MS = 3e4;
8783
8906
  var observationBase = {
8784
- role: Type15.String({ minLength: 1 }),
8785
- toolCallId: Type15.String({ minLength: 1 }),
8786
- toolName: Type15.String({ minLength: 1 }),
8787
- timestamp: Type15.String({ format: "date-time" })
8907
+ role: Type17.String({ minLength: 1 }),
8908
+ toolCallId: Type17.String({ minLength: 1 }),
8909
+ toolName: Type17.String({ minLength: 1 }),
8910
+ timestamp: Type17.String({ format: "date-time" })
8788
8911
  };
8789
- var toolExecutionObservationRecordSchema = Type15.Union([
8790
- Type15.Object({
8912
+ var toolExecutionObservationRecordSchema = Type17.Union([
8913
+ Type17.Object({
8791
8914
  ...observationBase,
8792
- event: Type15.Literal("tool_execution_start")
8915
+ event: Type17.Literal("tool_execution_start")
8793
8916
  }, { additionalProperties: true }),
8794
- Type15.Object({
8917
+ Type17.Object({
8795
8918
  ...observationBase,
8796
- event: Type15.Literal("tool_execution_update")
8919
+ event: Type17.Literal("tool_execution_update")
8797
8920
  }, { additionalProperties: true }),
8798
- Type15.Object({
8921
+ Type17.Object({
8799
8922
  ...observationBase,
8800
- event: Type15.Literal("tool_execution_end"),
8801
- isError: Type15.Boolean()
8923
+ event: Type17.Literal("tool_execution_end"),
8924
+ isError: Type17.Boolean()
8802
8925
  }, { additionalProperties: true })
8803
8926
  ]);
8804
8927
  function validateToolExecutionObservationRecord(record4) {
@@ -9177,24 +9300,24 @@ function assignWindowRelations(records2, activationTime, deadlineTime) {
9177
9300
  import Value4 from "typebox/value";
9178
9301
 
9179
9302
  // src/collector-tool-schemas.ts
9180
- import { Type as Type16 } from "typebox";
9181
- var collectorObserveArgsSchema = Type16.Object({}, { additionalProperties: false });
9182
- var collectorRequestArgsSchema = Type16.Object({
9183
- requestId: Type16.String({ minLength: 1, description: "\u914D\u7F6E\u8BF7\u6C42\u8EAB\u4EFD" }),
9184
- snapshotId: Type16.String({ minLength: 1, description: "\u6700\u65B0\u7559\u5B58\u89C2\u5BDF\u5FEB\u7167" })
9303
+ import { Type as Type18 } from "typebox";
9304
+ var collectorObserveArgsSchema = Type18.Object({}, { additionalProperties: false });
9305
+ var collectorRequestArgsSchema = Type18.Object({
9306
+ requestId: Type18.String({ minLength: 1, description: "\u914D\u7F6E\u8BF7\u6C42\u8EAB\u4EFD" }),
9307
+ snapshotId: Type18.String({ minLength: 1, description: "\u6700\u65B0\u7559\u5B58\u89C2\u5BDF\u5FEB\u7167" })
9185
9308
  }, { additionalProperties: false });
9186
- var collectorReadArgsSchema = Type16.Object({
9187
- evidenceId: Type16.String({ minLength: 1, description: "observe \u8FD4\u56DE\u7684\u6750\u6599\u8BC1\u636E id\uFF08evidenceId\uFF09" })
9309
+ var collectorReadArgsSchema = Type18.Object({
9310
+ evidenceId: Type18.String({ minLength: 1, description: "observe \u8FD4\u56DE\u7684\u6750\u6599\u8BC1\u636E id\uFF08evidenceId\uFF09" })
9188
9311
  }, { additionalProperties: false });
9189
- var collectorWaitArgsSchema = Type16.Object({
9190
- durationMs: Type16.Integer({ minimum: 1, maximum: COLLECTOR_ELIGIBILITY_MS, description: "\u7B49\u5F85\u6BEB\u79D2\uFF1B\u5355\u6B21\u4E0A\u9650\u4E94\u5206\u949F\u4E14\u4E0D\u8D85\u5269\u4F59\u8D44\u683C" })
9312
+ var collectorWaitArgsSchema = Type18.Object({
9313
+ durationMs: Type18.Integer({ minimum: 1, maximum: COLLECTOR_ELIGIBILITY_MS, description: "\u7B49\u5F85\u6BEB\u79D2\uFF1B\u5355\u6B21\u4E0A\u9650\u4E94\u5206\u949F\u4E14\u4E0D\u8D85\u5269\u4F59\u8D44\u683C" })
9191
9314
  }, { additionalProperties: false });
9192
- var collectorFindingArgsSchema = Type16.Object({
9193
- evidenceId: Type16.String({ minLength: 1, description: "observe \u8FD4\u56DE\u7684\u6750\u6599\u8BC1\u636E id\uFF08evidenceId\uFF09" }),
9194
- category: Type16.Optional(Type16.String({ minLength: 1, maxLength: 200, description: "\u8BE5 finding \u7684\u7B80\u77ED\u5F52\u7C7B\u6807\u7B7E\uFF1B\u9700\u8981\u5934\u90E8\u4E4B\u5916\u7684\u6B63\u6587\u65F6\u5148\u7528 ak_collector_read \u5F00\u5377\u518D\u5224\u8BFB\uFF0C\u4E0D\u5F97\u8A8A\u5199\u8BC4\u8BBA\u6B63\u6587" }))
9315
+ var collectorFindingArgsSchema = Type18.Object({
9316
+ evidenceId: Type18.String({ minLength: 1, description: "observe \u8FD4\u56DE\u7684\u6750\u6599\u8BC1\u636E id\uFF08evidenceId\uFF09" }),
9317
+ category: Type18.Optional(Type18.String({ minLength: 1, maxLength: 200, description: "\u8BE5 finding \u7684\u7B80\u77ED\u5F52\u7C7B\u6807\u7B7E\uFF1B\u9700\u8981\u5934\u90E8\u4E4B\u5916\u7684\u6B63\u6587\u65F6\u5148\u7528 ak_collector_read \u5F00\u5377\u518D\u5224\u8BFB\uFF0C\u4E0D\u5F97\u8A8A\u5199\u8BC4\u8BBA\u6B63\u6587" }))
9195
9318
  }, { additionalProperties: false });
9196
- var collectorOutputBaseSchema = Type16.Object({
9197
- findings: Type16.Optional(Type16.Array(collectorFindingArgsSchema, {
9319
+ var collectorOutputBaseSchema = Type18.Object({
9320
+ findings: Type18.Optional(Type18.Array(collectorFindingArgsSchema, {
9198
9321
  description: "\u672C\u6B21\u6536\u96C6\u5230\u7684\u9010\u6761 findings\uFF1B\u96F6 finding \u7684\u6A21\u677F\u901A\u77E5\u4E0D\u5F97\u8FDB\u5165\u3002\u6B63\u5E38\u5B8C\u5DE5\u65E0 finding \u65F6\u7701\u7565\u3002"
9199
9322
  }))
9200
9323
  }, { additionalProperties: true, description: "\u6B63\u5E38\u5B8C\u5DE5\u63D0\u4EA4\u7A7A\u5BF9\u8C61 {}\uFF1B\u4EC5\u5728\u57FA\u7840\u8BBE\u65BD\u771F\u5B9E\u5931\u8D25\u65F6\u624D\u586B\u5199 infrastructureFailure\uFF0C\u65E0\u5931\u8D25\u65F6\u5FC5\u987B\u7701\u7565\u8BE5\u5B57\u6BB5\u3002" });
@@ -10622,24 +10745,24 @@ function createNotaryRoleRuntime(pi, dependencies, host) {
10622
10745
  }
10623
10746
 
10624
10747
  // src/countersign-role.ts
10625
- import { Type as Type17 } from "typebox";
10748
+ import { Type as Type19 } from "typebox";
10626
10749
  var countersignVerdictSchema = withInfrastructureFailureDeclaration(
10627
- Type17.Object(
10750
+ Type19.Object(
10628
10751
  {
10629
10752
  countersignStatus: stringEnum(["converged", "continue", "escalate"], { description: "converged | continue | escalate" }),
10630
- fix: Type17.Optional(
10631
- Type17.Object(
10632
- { summary: Type17.String({ minLength: 1, description: "\u9000\u56DE\u6458\u8981" }) },
10753
+ fix: Type19.Optional(
10754
+ Type19.Object(
10755
+ { summary: Type19.String({ minLength: 1, description: "\u9000\u56DE\u6458\u8981" }) },
10633
10756
  { additionalProperties: false, description: "\u9000\u56DE\u8BF4\u660E" }
10634
10757
  )
10635
10758
  ),
10636
- note: Type17.Optional(Type17.String({ minLength: 1, description: "\u9644\u6CE8" })),
10637
- evidence: Type17.Optional(Type17.Unknown({ description: "\u7559\u5B58\u8BC1\u636E" })),
10638
- decisionGate: Type17.Optional(
10639
- Type17.Object(
10759
+ note: Type19.Optional(Type19.String({ minLength: 1, description: "\u9644\u6CE8" })),
10760
+ evidence: Type19.Optional(Type19.Unknown({ description: "\u7559\u5B58\u8BC1\u636E" })),
10761
+ decisionGate: Type19.Optional(
10762
+ Type19.Object(
10640
10763
  {
10641
- question: Type17.String({ minLength: 1 }),
10642
- options: Type17.Array(Type17.String({ minLength: 1 }), { minItems: 1 })
10764
+ question: Type19.String({ minLength: 1 }),
10765
+ options: Type19.Array(Type19.String({ minLength: 1 }), { minItems: 1 })
10643
10766
  },
10644
10767
  { additionalProperties: false, description: "\u9700\u965B\u4E0B\u5904\u7F6E\u7684\u95EE\u9898\u4E0E\u9009\u9879" }
10645
10768
  )
@@ -10658,18 +10781,18 @@ var COUNTERSIGN_TOOL_SPEC = {
10658
10781
  };
10659
10782
 
10660
10783
  // src/gleaner-left-role.ts
10661
- import { Type as Type18 } from "typebox";
10784
+ import { Type as Type20 } from "typebox";
10662
10785
  var gleanerLeftOutputSchema = withInfrastructureFailureDeclaration(
10663
10786
  openToolObject(
10664
- Type18.Object({
10665
- status: Type18.Unknown({
10787
+ Type20.Object({
10788
+ status: Type20.Unknown({
10666
10789
  description: "completed \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8"
10667
10790
  }),
10668
- findings: Type18.Array(
10669
- Type18.Object(
10791
+ findings: Type20.Array(
10792
+ Type20.Object(
10670
10793
  {
10671
- pointer: Type18.String({ description: "\u6587\u4EF6/\u884C\u6307\u9488" }),
10672
- statement: Type18.String({ description: "\u7591\u70B9\u9648\u8FF0" })
10794
+ pointer: Type20.String({ description: "\u6587\u4EF6/\u884C\u6307\u9488" }),
10795
+ statement: Type20.String({ description: "\u7591\u70B9\u9648\u8FF0" })
10673
10796
  },
10674
10797
  { additionalProperties: true, description: "\u4E00\u6761\u5F39\u7AE0" }
10675
10798
  ),
@@ -10686,26 +10809,216 @@ var GLEANER_LEFT_TOOL_SPEC = {
10686
10809
  parameters: gleanerLeftOutputSchema
10687
10810
  };
10688
10811
 
10689
- // src/inspector-role.ts
10690
- import { Type as Type19 } from "typebox";
10691
- var inspectorOutputSchema = withInfrastructureFailureDeclaration(
10692
- openToolObject(
10693
- Type19.Object({
10694
- status: Type19.Unknown({
10695
- description: "pass | bounce \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8"
10696
- }),
10697
- findings: Type19.Unknown({
10698
- description: "\u968F\u4EA4\u5377\u7559\u5B58\u7684\u95EE\u9898\u8BB0\u5F55"
10699
- })
10700
- })
10701
- )
10702
- );
10703
- var INSPECTOR_TOOL_SPEC = {
10704
- name: INSPECTOR_OUTPUT_TOOL_NAME,
10705
- label: "\u5BDF\u9662\u8F93\u51FA",
10706
- description: "\u5BDF\u9662\u7EC8\u5C40\u56DE\u6267\uFF0C\u72B6\u6001\u4E3A pass \u6216 bounce\u3002",
10707
- promptSnippet: "\u5BDF\u9662\u7EC8\u5C40\u56DE\u6267",
10708
- parameters: inspectorOutputSchema
10812
+ // src/inspector-role.ts
10813
+ import { Type as Type21 } from "typebox";
10814
+ var inspectorOutputSchema = withInfrastructureFailureDeclaration(
10815
+ openToolObject(
10816
+ Type21.Object({
10817
+ status: Type21.Unknown({
10818
+ description: "pass | bounce \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8"
10819
+ }),
10820
+ findings: Type21.Unknown({
10821
+ description: "\u968F\u4EA4\u5377\u7559\u5B58\u7684\u95EE\u9898\u8BB0\u5F55"
10822
+ })
10823
+ })
10824
+ )
10825
+ );
10826
+ var INSPECTOR_TOOL_SPEC = {
10827
+ name: INSPECTOR_OUTPUT_TOOL_NAME,
10828
+ label: "\u5BDF\u9662\u8F93\u51FA",
10829
+ description: "\u5BDF\u9662\u7EC8\u5C40\u56DE\u6267\uFF0C\u72B6\u6001\u4E3A pass \u6216 bounce\u3002",
10830
+ promptSnippet: "\u5BDF\u9662\u7EC8\u5C40\u56DE\u6267",
10831
+ parameters: inspectorOutputSchema
10832
+ };
10833
+
10834
+ // src/gatekeeper-role.ts
10835
+ import { Type as Type22 } from "typebox";
10836
+ var INSPECTOR_OUTPUT_TOOL = INSPECTOR_OUTPUT_TOOL_NAME;
10837
+ var NOTARY_OUTPUT_TOOL = "ak_notary_output";
10838
+ var SUBJECT_TOOL = "ak_gatekeeper_subject";
10839
+ function gateSeatLabel(stage) {
10840
+ switch (stage) {
10841
+ case "gatekeeper":
10842
+ return "\u95E8\u4E0B\u7701";
10843
+ case "inspector":
10844
+ return "\u5BDF\u9662";
10845
+ case "notary":
10846
+ return "\u7B26\u5B9D\u90CE";
10847
+ }
10848
+ }
10849
+ var officerDecisionSchema = openToolObject(Type22.Object({
10850
+ status: Type22.Unknown({ description: "pass | bounce \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8" }),
10851
+ findings: Type22.Unknown({ description: "string[] findings\uFF0C\u968F pass \u6216 bounce \u7559\u5B58" })
10852
+ }));
10853
+ var GATEKEEPER_TOOL_SPEC = {
10854
+ name: GATEKEEPER_OUTPUT_TOOL_NAME,
10855
+ label: "\u95E8\u4E0B\u7701\u51B3\u8BAE",
10856
+ description: "\u95E8\u4E0B\u7701\u7EC8\u5C40\u51B3\u8BAE\uFF0C\u72B6\u6001\u4E3A dispatch \u6216 pass\u3002",
10857
+ promptSnippet: "\u95E8\u4E0B\u7701\u51B3\u8BAE",
10858
+ parameters: gatekeeperOutputSchema
10859
+ };
10860
+ function result(content, details) {
10861
+ return { content: [{ type: "text", text: content }], details };
10862
+ }
10863
+ function subjectTool(subject) {
10864
+ return {
10865
+ name: SUBJECT_TOOL,
10866
+ description: "\u8BFB\u53D6\u5DF2\u53D7\u7406\u5377\u5B97\uFF1B\u53EA\u4F9B\u53D6\u9605\uFF0C\u4E0D\u8BC4\u5224\u4E0D\u6539\u52A8\u3002",
10867
+ parameters: Type22.Object({}, { additionalProperties: false }),
10868
+ async execute() {
10869
+ return result(JSON.stringify(subject), subject);
10870
+ }
10871
+ };
10872
+ }
10873
+ function createOfficerDecisionTool(name) {
10874
+ return {
10875
+ name,
10876
+ description: "\u63D0\u4EA4\u4E00\u4EFD typed pass/bounce \u51B3\u8BAE\u3002",
10877
+ parameters: officerDecisionSchema,
10878
+ async execute(_id, args) {
10879
+ return result(`\u5DF2\u6536 ${String(args?.status)}`, args);
10880
+ }
10881
+ };
10882
+ }
10883
+ function createGatekeeperOutputTool() {
10884
+ return {
10885
+ name: GATEKEEPER_OUTPUT_TOOL_NAME,
10886
+ description: "\u63D0\u4EA4\u95E8\u4E0B\u7701\u6D3E\u5B98\u51B3\u5B9A\u3002",
10887
+ parameters: gatekeeperDecisionSchema,
10888
+ async execute(_id, args) {
10889
+ return result(`\u5DF2\u6536 ${String(args?.status)}`, args);
10890
+ }
10891
+ };
10892
+ }
10893
+ async function defaultLoadSoul(role) {
10894
+ return loadGatekeeperSessionMaterials(role);
10895
+ }
10896
+ function failureReason(error) {
10897
+ if (error instanceof AggregateError) return error.errors.map(failureReason).join("; ");
10898
+ return error instanceof Error ? `${error.name}: ${error.message}` : String(error);
10899
+ }
10900
+ function asStringArray3(value) {
10901
+ if (!Array.isArray(value)) return [];
10902
+ return value.filter((item) => typeof item === "string");
10903
+ }
10904
+ var MISSING_ARGUMENTS_SUBMISSION = Object.freeze({ missing: "arguments" });
10905
+ function isRecord11(value) {
10906
+ return typeof value === "object" && value !== null && !Array.isArray(value);
10907
+ }
10908
+ function retainedSubmission(decision) {
10909
+ return decision === void 0 || isRecord11(decision) && Object.keys(decision).length === 0 ? MISSING_ARGUMENTS_SUBMISSION : decision;
10910
+ }
10911
+ function noUsableReleaseFailure(stage, decision) {
10912
+ return {
10913
+ status: "transport_failure",
10914
+ stage,
10915
+ reason: stage === "gatekeeper" ? "decision \u65E0\u663E\u5F0F dispatch" : "decision \u65E0\u663E\u5F0F pass/bounce",
10916
+ submission: retainedSubmission(decision)
10917
+ };
10918
+ }
10919
+ function readRecord(value) {
10920
+ if (typeof value !== "object" || value === null || Array.isArray(value)) return void 0;
10921
+ return value;
10922
+ }
10923
+ function projectProvinceDecision(decision) {
10924
+ const projected = projectLawfulGatekeeperOutput(decision);
10925
+ if (projected === void 0) return noUsableReleaseFailure("gatekeeper", decision);
10926
+ if (projected.status === "dispatch") {
10927
+ return { status: "dispatch", officer: projected.officer };
10928
+ }
10929
+ return { status: "pass", findings: projected.findings ?? [] };
10930
+ }
10931
+ function projectOfficerDecision(officer, decision) {
10932
+ const record4 = readRecord(decision);
10933
+ if (record4 === void 0) return noUsableReleaseFailure(officer, decision);
10934
+ if (record4.status === "bounce") {
10935
+ return {
10936
+ status: "bounce",
10937
+ officer,
10938
+ disposition: "rewrite",
10939
+ findings: asStringArray3(record4.findings),
10940
+ submission: retainedSubmission(decision)
10941
+ };
10942
+ }
10943
+ if (record4.status === "pass") {
10944
+ return {
10945
+ status: "pass",
10946
+ officer,
10947
+ findings: asStringArray3(record4.findings)
10948
+ };
10949
+ }
10950
+ return noUsableReleaseFailure(officer, decision);
10951
+ }
10952
+ async function runGatekeeper(options) {
10953
+ const loadSoul = options.loadSoul ?? defaultLoadSoul;
10954
+ let provinceRun;
10955
+ try {
10956
+ provinceRun = await executeAuditorChild({
10957
+ context: options.context,
10958
+ roleLabel: "Gatekeeper",
10959
+ gateSeat: "gatekeeper",
10960
+ systemPrompt: await loadSoul("gatekeeper"),
10961
+ prompt: "\u5377\u5B97\u5DF2\u53D7\u7406\u3002",
10962
+ tool: createGatekeeperOutputTool(),
10963
+ dossierTool: subjectTool(options.subject),
10964
+ ...options.signal === void 0 ? {} : { signal: options.signal },
10965
+ ...options.runDirectory === void 0 ? {} : { runDirectory: options.runDirectory }
10966
+ });
10967
+ } catch (error) {
10968
+ return { status: "transport_failure", stage: "gatekeeper", reason: failureReason(error) };
10969
+ }
10970
+ if (provinceRun.noReceiptLifecycle !== void 0) {
10971
+ return { status: "no_receipt", stage: "gatekeeper", reason: `${gateSeatLabel("gatekeeper")}\u672A\u4EA7\u751F\u5DF2\u63A5\u53D7\u56DE\u6267\u5373\u6563\u5C40`, facts: provinceRun.noReceiptLifecycle };
10972
+ }
10973
+ const province = projectProvinceDecision(provinceRun.decision);
10974
+ if (province.status !== "dispatch") return province;
10975
+ const officer = province.officer;
10976
+ try {
10977
+ const roleLabel = officer === "inspector" ? "Inspector" : "Notary";
10978
+ const officerRun = await executeAuditorChild({
10979
+ context: options.context,
10980
+ roleLabel,
10981
+ gateSeat: officer,
10982
+ systemPrompt: await loadSoul(officer),
10983
+ prompt: "\u5377\u5B97\u5DF2\u53D7\u7406\u3002",
10984
+ tool: createOfficerDecisionTool(officer === "inspector" ? INSPECTOR_OUTPUT_TOOL : NOTARY_OUTPUT_TOOL),
10985
+ dossierTool: subjectTool(options.subject),
10986
+ ...options.signal === void 0 ? {} : { signal: options.signal },
10987
+ ...options.runDirectory === void 0 ? {} : { runDirectory: options.runDirectory }
10988
+ });
10989
+ if (officerRun.noReceiptLifecycle !== void 0) {
10990
+ return { status: "no_receipt", stage: officer, reason: `${gateSeatLabel(officer)}\u672A\u4EA7\u751F\u5DF2\u63A5\u53D7\u56DE\u6267\u5373\u6563\u5C40`, facts: officerRun.noReceiptLifecycle };
10991
+ }
10992
+ return projectOfficerDecision(officer, officerRun.decision);
10993
+ } catch (error) {
10994
+ return { status: "transport_failure", stage: officer, reason: failureReason(error) };
10995
+ }
10996
+ }
10997
+ async function requireGatekeeperPass(options) {
10998
+ const gatekeeper = await runGatekeeper({
10999
+ context: options.context,
11000
+ subject: options.subject,
11001
+ ...options.signal === void 0 ? {} : { signal: options.signal }
11002
+ });
11003
+ if (gatekeeper.status === "pass") return;
11004
+ if (gatekeeper.status === "transport_failure") {
11005
+ const error = new Error(`\u95E8\u4E0B\u7701 transport_failure\uFF08${gatekeeper.stage}\uFF09\uFF1A${gatekeeper.reason}`);
11006
+ error.stage = gatekeeper.stage;
11007
+ error.reason = gatekeeper.reason;
11008
+ if (gatekeeper.submission !== void 0) error.submission = gatekeeper.submission;
11009
+ options.hostActions.failInfrastructure(error, options.context, options.toolCallId);
11010
+ }
11011
+ options.hostActions.bindSubmissionNonPass(options.toolCallId, gatekeeper);
11012
+ throw new GatekeeperDecisionError(gatekeeper);
11013
+ }
11014
+
11015
+ // src/navigator-role.ts
11016
+ var NAVIGATOR_TOOL_SPEC = {
11017
+ name: NAVIGATOR_OUTPUT_TOOL_NAME,
11018
+ label: "\u6E38\u5955\u4F7F\u5EFA\u8BAE",
11019
+ description: "\u6E38\u5955\u4F7F\u7EC8\u5C40\u56DE\u6267\uFF1A\u6392\u597D\u5E8F\u7684\u4E0B\u4E00\u6B65\u89D2\u8272\u8DEF\u7EBF\u5EFA\u8BAE\u3002",
11020
+ promptSnippet: "\u6E38\u5955\u4F7F\u5EFA\u8BAE",
11021
+ parameters: navigatorOutputSchema
10709
11022
  };
10710
11023
 
10711
11024
  // src/pi/known-failure.ts
@@ -10738,30 +11051,30 @@ function raceNavigatorGrace(work, graceMs = NAVIGATOR_POST_ROLE_GRACE_MS, sleep
10738
11051
  }
10739
11052
 
10740
11053
  // src/judge-role.ts
10741
- import { Type as Type20 } from "typebox";
11054
+ import { Type as Type23 } from "typebox";
10742
11055
  var judgeVerdictSchema = withInfrastructureFailureDeclaration(
10743
- Type20.Object(
11056
+ Type23.Object(
10744
11057
  {
10745
11058
  judgeStatus: stringEnum(["converged", "continue", "escalate"], { description: "converged | continue | escalate \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8" }),
10746
- fix: Type20.Optional(
10747
- Type20.Object(
10748
- { summary: Type20.String({ minLength: 1, description: "continue \u65F6\u7684\u8865\u6551\u6458\u8981" }) },
11059
+ fix: Type23.Optional(
11060
+ Type23.Object(
11061
+ { summary: Type23.String({ minLength: 1, description: "continue \u65F6\u7684\u8865\u6551\u6458\u8981" }) },
10749
11062
  { additionalProperties: false, description: "continue \u65F6\u7684\u8865\u6551\u8BF4\u660E" }
10750
11063
  )
10751
11064
  ),
10752
- classes: Type20.Optional(Type20.Array(Type20.Object({
10753
- name: Type20.String({ minLength: 1 }),
10754
- owner: Type20.String({ minLength: 1 }),
10755
- boundary: Type20.String({ minLength: 1 }),
10756
- disposition: Type20.String({ minLength: 1 })
11065
+ classes: Type23.Optional(Type23.Array(Type23.Object({
11066
+ name: Type23.String({ minLength: 1 }),
11067
+ owner: Type23.String({ minLength: 1 }),
11068
+ boundary: Type23.String({ minLength: 1 }),
11069
+ disposition: Type23.String({ minLength: 1 })
10757
11070
  }, { additionalProperties: false }), { minItems: 1, description: "\u5DF2\u88C1\u51B3 finding \u7C7B\u53CA\u5176 owner \u4E0E\u4FEE\u7406\u8FB9\u754C" })),
10758
- note: Type20.Optional(Type20.String({ minLength: 1, description: "\u53EF\u9009\u88C1\u51B3\u9644\u6CE8" })),
10759
- evidence: Type20.Optional(Type20.Unknown({ description: "\u7559\u5B58\u7684\u88C1\u51B3\u8BC1\u636E" })),
10760
- decisionGate: Type20.Optional(
10761
- Type20.Object(
11071
+ note: Type23.Optional(Type23.String({ minLength: 1, description: "\u53EF\u9009\u88C1\u51B3\u9644\u6CE8" })),
11072
+ evidence: Type23.Optional(Type23.Unknown({ description: "\u7559\u5B58\u7684\u88C1\u51B3\u8BC1\u636E" })),
11073
+ decisionGate: Type23.Optional(
11074
+ Type23.Object(
10762
11075
  {
10763
- question: Type20.String({ minLength: 1 }),
10764
- options: Type20.Array(Type20.String({ minLength: 1 }), { minItems: 1 })
11076
+ question: Type23.String({ minLength: 1 }),
11077
+ options: Type23.Array(Type23.String({ minLength: 1 }), { minItems: 1 })
10765
11078
  },
10766
11079
  { additionalProperties: false, description: "\u9700\u4EBA\u6743\u5A01\u5904\u7F6E\u7684\u95EE\u9898\u4E0E\u9009\u9879" }
10767
11080
  )
@@ -10851,7 +11164,7 @@ ${soul}
10851
11164
  }
10852
11165
 
10853
11166
  // src/reviewer-role.ts
10854
- import { Type as Type21 } from "typebox";
11167
+ import { Type as Type24 } from "typebox";
10855
11168
 
10856
11169
  // src/reviewer-execution-ledger.ts
10857
11170
  function projectAcceptedDispatch(dispatch) {
@@ -11057,19 +11370,19 @@ function assembleRuntimeReviewerReceipt(input) {
11057
11370
  }
11058
11371
 
11059
11372
  // src/reviewer-role.ts
11060
- var reviewerAmendmentsSchema = Type21.Object({
11061
- standards: Type21.Optional(Type21.String({ description: "\u76F8\u5BF9 Standards \u5B50\u62A5\u544A\u7684\u589E\u91CF\uFF1A\u589E finding\u3001\u64A4\u56DE\u6216\u4E8B\u5B9E\u66F4\u6B63" })),
11062
- spec: Type21.Optional(Type21.String({ description: "\u76F8\u5BF9 Spec \u5B50\u62A5\u544A\u7684\u589E\u91CF\uFF1A\u589E finding\u3001\u64A4\u56DE\u6216\u4E8B\u5B9E\u66F4\u6B63" }))
11373
+ var reviewerAmendmentsSchema = Type24.Object({
11374
+ standards: Type24.Optional(Type24.String({ description: "\u76F8\u5BF9 Standards \u5B50\u62A5\u544A\u7684\u589E\u91CF\uFF1A\u589E finding\u3001\u64A4\u56DE\u6216\u4E8B\u5B9E\u66F4\u6B63" })),
11375
+ spec: Type24.Optional(Type24.String({ description: "\u76F8\u5BF9 Spec \u5B50\u62A5\u544A\u7684\u589E\u91CF\uFF1A\u589E finding\u3001\u64A4\u56DE\u6216\u4E8B\u5B9E\u66F4\u6B63" }))
11063
11376
  }, { additionalProperties: true, description: "\u76F8\u5BF9\u5B50\u62A5\u544A\u7684\u53EF\u9009\u8F74\u589E\u91CF\uFF1B\u975E\u66FF\u4EE3\u62A5\u544A\u3002\u65E0\u589E\u91CF\u7684\u8F74\u53EF\u7701\u7565\u3002" });
11064
- var reviewerOutputVariants = Type21.Union([
11065
- Type21.Object({
11066
- status: Type21.Literal("completed", { description: "completed \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8" }),
11067
- amendments: Type21.Optional(reviewerAmendmentsSchema)
11377
+ var reviewerOutputVariants = Type24.Union([
11378
+ Type24.Object({
11379
+ status: Type24.Literal("completed", { description: "completed \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8" }),
11380
+ amendments: Type24.Optional(reviewerAmendmentsSchema)
11068
11381
  }, { additionalProperties: false }),
11069
- Type21.Object({
11070
- status: Type21.Literal("refused", { description: "refused \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8" }),
11071
- diagnostic: Type21.String({ minLength: 1, description: "\u62D2\u7EDD\u8BCA\u65AD\u8BF4\u660E" }),
11072
- amendments: Type21.Optional(reviewerAmendmentsSchema)
11382
+ Type24.Object({
11383
+ status: Type24.Literal("refused", { description: "refused \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8" }),
11384
+ diagnostic: Type24.String({ minLength: 1, description: "\u62D2\u7EDD\u8BCA\u65AD\u8BF4\u660E" }),
11385
+ amendments: Type24.Optional(reviewerAmendmentsSchema)
11073
11386
  }, { additionalProperties: false })
11074
11387
  ]);
11075
11388
  var reviewerOutputSchema = withInfrastructureFailureDeclaration(
@@ -11197,7 +11510,7 @@ function createReviewerRoleRuntime(pi, dependencies, hostActions) {
11197
11510
  }
11198
11511
 
11199
11512
  // src/worker-role.ts
11200
- import { Type as Type22 } from "typebox";
11513
+ import { Type as Type25 } from "typebox";
11201
11514
 
11202
11515
  // src/worker-submission-gates.ts
11203
11516
  init_archivist_record_entry();
@@ -11299,7 +11612,7 @@ function uninstallPackageWorkerHooks(cwd) {
11299
11612
  rmOwnedDir(resolve16(gitDir, HOOKS_DIR));
11300
11613
  }
11301
11614
  }
11302
- function isRecord9(value) {
11615
+ function isRecord12(value) {
11303
11616
  return typeof value === "object" && value !== null && !Array.isArray(value);
11304
11617
  }
11305
11618
  function unfinishedReasonPresent(details) {
@@ -11315,7 +11628,7 @@ function readGateState(session) {
11315
11628
  if (entry.type !== "custom") continue;
11316
11629
  if (entry.customType === WORKER_COMMIT_BASELINE_ENTRY_TYPE) {
11317
11630
  const data = entry.data;
11318
- if (isRecord9(data) && (data.head === null || typeof data.head === "string")) {
11631
+ if (isRecord12(data) && (data.head === null || typeof data.head === "string")) {
11319
11632
  baseline = data.head;
11320
11633
  }
11321
11634
  } else if (entry.customType === WORKER_COMMIT_REMINDER_BOUNCE_ENTRY_TYPE) {
@@ -11458,24 +11771,24 @@ function fixerBashSeatbeltDenyReason(matched) {
11458
11771
  }
11459
11772
 
11460
11773
  // src/worker-role.ts
11461
- var coderOutputVariants = Type22.Union([
11462
- Type22.Object({
11774
+ var coderOutputVariants = Type25.Union([
11775
+ Type25.Object({
11463
11776
  status: stringEnum(["planned"], { description: "planned \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8" }),
11464
- report: Type22.String({ minLength: 1, description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" })
11777
+ report: Type25.String({ minLength: 1, description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" })
11465
11778
  }, { additionalProperties: false }),
11466
- Type22.Object({
11779
+ Type25.Object({
11467
11780
  status: stringEnum(["completed", "refused"], {
11468
11781
  description: "completed | refused \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8\uFF1Bcompleted \u56DE\u6267\u542B TDD\u3001\u540C\u6A21\u5F0F\u3001\u5F15\u5165\u56DE\u5F52\u3001\u884C\u4E3A\u4E8B\u5B9E\u56DB\u9879\u8BC1\u636E"
11469
11782
  }),
11470
- report: Type22.String({ minLength: 1, description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" })
11783
+ report: Type25.String({ minLength: 1, description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" })
11471
11784
  }, { additionalProperties: false }),
11472
- Type22.Object({
11785
+ Type25.Object({
11473
11786
  status: stringEnum(["unfinished"], {
11474
11787
  description: "unfinished \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8\uFF1B\u7F3A\u524D\u7F6E\u6216\u8FDD\u5BAA\u7EA6\u675F\u81F4\u672C\u5C40\u672A\u5B8C\u6210\u65F6\u53EF\u7528\u3002\u7F3A\u5F85\u51B3 owner \u51B3\u5B9A\u6216\u7B54\u590D\u5C5E\u7F3A\u524D\u7F6E\u3002"
11475
11788
  }),
11476
- report: Type22.String({ minLength: 1, description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }),
11477
- remainingScope: Type22.String({ minLength: 1, description: "\u672C\u5C40\u540E\u5269\u4F59\u5DE5\u4F5C" }),
11478
- reason: Type22.Optional(Type22.String({
11789
+ report: Type25.String({ minLength: 1, description: "\u5982\u5B9E\u7ED3\u679C\u62A5\u544A" }),
11790
+ remainingScope: Type25.String({ minLength: 1, description: "\u672C\u5C40\u540E\u5269\u4F59\u5DE5\u4F5C" }),
11791
+ reason: Type25.Optional(Type25.String({
11479
11792
  minLength: 1,
11480
11793
  description: "\u963B\u65AD\u539F\u56E0\uFF1A\u7F3A\u524D\u7F6E\u6216\u8FDD\u5BAA\u7EA6\u675F\u3002\u7F3A\u5F85\u51B3 owner \u51B3\u5B9A\u6216\u7B54\u590D\u5C5E\u7F3A\u524D\u7F6E\u3002"
11481
11794
  }))
@@ -11893,189 +12206,6 @@ ${JSON.stringify(admitted)}
11893
12206
  } };
11894
12207
  }
11895
12208
 
11896
- // src/gatekeeper-role.ts
11897
- import { Type as Type23 } from "typebox";
11898
- var GATEKEEPER_OUTPUT_TOOL = "ak_gatekeeper_output";
11899
- var INSPECTOR_OUTPUT_TOOL = INSPECTOR_OUTPUT_TOOL_NAME;
11900
- var NOTARY_OUTPUT_TOOL = "ak_notary_output";
11901
- var SUBJECT_TOOL = "ak_gatekeeper_subject";
11902
- function gateSeatLabel(stage) {
11903
- switch (stage) {
11904
- case "gatekeeper":
11905
- return "\u95E8\u4E0B\u7701";
11906
- case "inspector":
11907
- return "\u5BDF\u9662";
11908
- case "notary":
11909
- return "\u7B26\u5B9D\u90CE";
11910
- }
11911
- }
11912
- var officerDecisionSchema = openToolObject(Type23.Object({
11913
- status: Type23.Unknown({ description: "pass | bounce \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8" }),
11914
- findings: Type23.Unknown({ description: "string[] findings\uFF0C\u968F pass \u6216 bounce \u7559\u5B58" })
11915
- }));
11916
- var gatekeeperDecisionSchema = openToolObject(Type23.Object({
11917
- status: Type23.Unknown({ description: "dispatch | pass \u2014 \u5F62\u72B6\u6307\u5F15\uFF0C\u975E schema \u95F8" }),
11918
- officer: Type23.Unknown({ description: "status \u4E3A dispatch \u65F6\u4E3A inspector | notary" }),
11919
- findings: Type23.Unknown({ description: "status \u4E3A pass \u65F6\u53EF\u9009 string[] findings" })
11920
- }));
11921
- function result(content, details) {
11922
- return { content: [{ type: "text", text: content }], details };
11923
- }
11924
- function subjectTool(subject) {
11925
- return {
11926
- name: SUBJECT_TOOL,
11927
- description: "\u8BFB\u53D6\u5DF2\u53D7\u7406\u5377\u5B97\uFF1B\u53EA\u4F9B\u53D6\u9605\uFF0C\u4E0D\u8BC4\u5224\u4E0D\u6539\u52A8\u3002",
11928
- parameters: Type23.Object({}, { additionalProperties: false }),
11929
- async execute() {
11930
- return result(JSON.stringify(subject), subject);
11931
- }
11932
- };
11933
- }
11934
- function createOfficerDecisionTool(name) {
11935
- return {
11936
- name,
11937
- description: "\u63D0\u4EA4\u4E00\u4EFD typed pass/bounce \u51B3\u8BAE\u3002",
11938
- parameters: officerDecisionSchema,
11939
- async execute(_id, args) {
11940
- return result(`\u5DF2\u6536 ${String(args?.status)}`, args);
11941
- }
11942
- };
11943
- }
11944
- function createGatekeeperOutputTool() {
11945
- return {
11946
- name: GATEKEEPER_OUTPUT_TOOL,
11947
- description: "\u63D0\u4EA4\u95E8\u4E0B\u7701\u6D3E\u5B98\u51B3\u5B9A\u3002",
11948
- parameters: gatekeeperDecisionSchema,
11949
- async execute(_id, args) {
11950
- return result(`\u5DF2\u6536 ${String(args?.status)}`, args);
11951
- }
11952
- };
11953
- }
11954
- async function defaultLoadSoul(role) {
11955
- return loadGatekeeperSessionMaterials(role);
11956
- }
11957
- function failureReason(error) {
11958
- if (error instanceof AggregateError) return error.errors.map(failureReason).join("; ");
11959
- return error instanceof Error ? `${error.name}: ${error.message}` : String(error);
11960
- }
11961
- function asStringArray2(value) {
11962
- if (!Array.isArray(value)) return [];
11963
- return value.filter((item) => typeof item === "string");
11964
- }
11965
- var MISSING_ARGUMENTS_SUBMISSION = Object.freeze({ missing: "arguments" });
11966
- function isRecord10(value) {
11967
- return typeof value === "object" && value !== null && !Array.isArray(value);
11968
- }
11969
- function retainedSubmission(decision) {
11970
- return decision === void 0 || isRecord10(decision) && Object.keys(decision).length === 0 ? MISSING_ARGUMENTS_SUBMISSION : decision;
11971
- }
11972
- function noUsableReleaseFailure(stage, decision) {
11973
- return {
11974
- status: "transport_failure",
11975
- stage,
11976
- reason: stage === "gatekeeper" ? "decision \u65E0\u663E\u5F0F dispatch" : "decision \u65E0\u663E\u5F0F pass/bounce",
11977
- submission: retainedSubmission(decision)
11978
- };
11979
- }
11980
- function readRecord(value) {
11981
- if (typeof value !== "object" || value === null || Array.isArray(value)) return void 0;
11982
- return value;
11983
- }
11984
- function projectProvinceDecision(decision) {
11985
- const record4 = readRecord(decision);
11986
- if (record4 === void 0) return noUsableReleaseFailure("gatekeeper", decision);
11987
- if (record4.status === "dispatch" && (record4.officer === "inspector" || record4.officer === "notary")) {
11988
- return { status: "dispatch", officer: record4.officer };
11989
- }
11990
- if (record4.status === "pass") {
11991
- return { status: "pass", findings: asStringArray2(record4.findings) };
11992
- }
11993
- return noUsableReleaseFailure("gatekeeper", decision);
11994
- }
11995
- function projectOfficerDecision(officer, decision) {
11996
- const record4 = readRecord(decision);
11997
- if (record4 === void 0) return noUsableReleaseFailure(officer, decision);
11998
- if (record4.status === "bounce") {
11999
- return {
12000
- status: "bounce",
12001
- officer,
12002
- disposition: "rewrite",
12003
- findings: asStringArray2(record4.findings),
12004
- submission: retainedSubmission(decision)
12005
- };
12006
- }
12007
- if (record4.status === "pass") {
12008
- return {
12009
- status: "pass",
12010
- officer,
12011
- findings: asStringArray2(record4.findings)
12012
- };
12013
- }
12014
- return noUsableReleaseFailure(officer, decision);
12015
- }
12016
- async function runGatekeeper(options) {
12017
- const loadSoul = options.loadSoul ?? defaultLoadSoul;
12018
- let provinceRun;
12019
- try {
12020
- provinceRun = await executeAuditorChild({
12021
- context: options.context,
12022
- roleLabel: "Gatekeeper",
12023
- gateSeat: "gatekeeper",
12024
- systemPrompt: await loadSoul("gatekeeper"),
12025
- prompt: "\u5377\u5B97\u5DF2\u53D7\u7406\u3002",
12026
- tool: createGatekeeperOutputTool(),
12027
- dossierTool: subjectTool(options.subject),
12028
- ...options.signal === void 0 ? {} : { signal: options.signal },
12029
- ...options.runDirectory === void 0 ? {} : { runDirectory: options.runDirectory }
12030
- });
12031
- } catch (error) {
12032
- return { status: "transport_failure", stage: "gatekeeper", reason: failureReason(error) };
12033
- }
12034
- if (provinceRun.noReceiptLifecycle !== void 0) {
12035
- return { status: "no_receipt", stage: "gatekeeper", reason: `${gateSeatLabel("gatekeeper")}\u672A\u4EA7\u751F\u5DF2\u63A5\u53D7\u56DE\u6267\u5373\u6563\u5C40`, facts: provinceRun.noReceiptLifecycle };
12036
- }
12037
- const province = projectProvinceDecision(provinceRun.decision);
12038
- if (province.status !== "dispatch") return province;
12039
- const officer = province.officer;
12040
- try {
12041
- const roleLabel = officer === "inspector" ? "Inspector" : "Notary";
12042
- const officerRun = await executeAuditorChild({
12043
- context: options.context,
12044
- roleLabel,
12045
- gateSeat: officer,
12046
- systemPrompt: await loadSoul(officer),
12047
- prompt: "\u5377\u5B97\u5DF2\u53D7\u7406\u3002",
12048
- tool: createOfficerDecisionTool(officer === "inspector" ? INSPECTOR_OUTPUT_TOOL : NOTARY_OUTPUT_TOOL),
12049
- dossierTool: subjectTool(options.subject),
12050
- ...options.signal === void 0 ? {} : { signal: options.signal },
12051
- ...options.runDirectory === void 0 ? {} : { runDirectory: options.runDirectory }
12052
- });
12053
- if (officerRun.noReceiptLifecycle !== void 0) {
12054
- return { status: "no_receipt", stage: officer, reason: `${gateSeatLabel(officer)}\u672A\u4EA7\u751F\u5DF2\u63A5\u53D7\u56DE\u6267\u5373\u6563\u5C40`, facts: officerRun.noReceiptLifecycle };
12055
- }
12056
- return projectOfficerDecision(officer, officerRun.decision);
12057
- } catch (error) {
12058
- return { status: "transport_failure", stage: officer, reason: failureReason(error) };
12059
- }
12060
- }
12061
- async function requireGatekeeperPass(options) {
12062
- const gatekeeper = await runGatekeeper({
12063
- context: options.context,
12064
- subject: options.subject,
12065
- ...options.signal === void 0 ? {} : { signal: options.signal }
12066
- });
12067
- if (gatekeeper.status === "pass") return;
12068
- if (gatekeeper.status === "transport_failure") {
12069
- const error = new Error(`\u95E8\u4E0B\u7701 transport_failure\uFF08${gatekeeper.stage}\uFF09\uFF1A${gatekeeper.reason}`);
12070
- error.stage = gatekeeper.stage;
12071
- error.reason = gatekeeper.reason;
12072
- if (gatekeeper.submission !== void 0) error.submission = gatekeeper.submission;
12073
- options.hostActions.failInfrastructure(error, options.context, options.toolCallId);
12074
- }
12075
- options.hostActions.bindSubmissionNonPass(options.toolCallId, gatekeeper);
12076
- throw new GatekeeperDecisionError(gatekeeper);
12077
- }
12078
-
12079
12209
  // src/role-runtime.ts
12080
12210
  var REVIEWER_TRANSPORT_FLAGS = Object.freeze([
12081
12211
  Object.freeze({
@@ -12241,6 +12371,10 @@ function activationStage(role, runtime) {
12241
12371
  return { id: "load-and-install", run: async () => runtime.gleanerLeft.activate() };
12242
12372
  case "inspector":
12243
12373
  return { id: "load-and-install", run: async () => runtime.inspector.activate() };
12374
+ case "gatekeeper":
12375
+ return { id: "load-and-install", run: async () => runtime.gatekeeper.activate() };
12376
+ case "navigator":
12377
+ return { id: "load-and-install", run: async () => runtime.navigator.activate() };
12244
12378
  case "merger":
12245
12379
  return { id: "prepare-git-and-install", run: async () => runtime.merger() };
12246
12380
  }
@@ -12514,6 +12648,30 @@ function createInspectorRoleRuntime(roleHost, dependencies) {
12514
12648
  dependencies
12515
12649
  );
12516
12650
  }
12651
+ function createGatekeeperRoleRuntime(roleHost, dependencies) {
12652
+ return createFiledOfficerRuntime(
12653
+ roleHost,
12654
+ {
12655
+ role: "gatekeeper",
12656
+ tool: GATEKEEPER_TOOL_SPEC,
12657
+ acceptedText: GATEKEEPER_ACCEPTED_TEXT,
12658
+ soulTag: "gatekeeper"
12659
+ },
12660
+ dependencies
12661
+ );
12662
+ }
12663
+ function createNavigatorRoleRuntime(roleHost, dependencies) {
12664
+ return createFiledOfficerRuntime(
12665
+ roleHost,
12666
+ {
12667
+ role: "navigator",
12668
+ tool: NAVIGATOR_TOOL_SPEC,
12669
+ acceptedText: NAVIGATOR_ACCEPTED_TEXT,
12670
+ soulTag: "navigator"
12671
+ },
12672
+ dependencies
12673
+ );
12674
+ }
12517
12675
  function createCountersignRoleRuntime(roleHost, dependencies, hostActions) {
12518
12676
  const beforeAccept = hostActions !== void 0 && roleHost.requireGatekeeperPass !== void 0 ? async ({ toolCallId, parameters, signal, ctx }) => {
12519
12677
  const material = await buildCountersignNotaryGateMaterial({
@@ -12942,6 +13100,18 @@ function createRoleRuntimeExtension(dependencies) {
12942
13100
  return dependencies.loadInspectorSoul();
12943
13101
  }
12944
13102
  });
13103
+ const gatekeeper = createGatekeeperRoleRuntime(roleHost, {
13104
+ async loadSoul() {
13105
+ if (!dependencies.loadGatekeeperSoul) throw new Error("Gatekeeper runtime dependencies are not configured");
13106
+ return dependencies.loadGatekeeperSoul();
13107
+ }
13108
+ });
13109
+ const navigator = createNavigatorRoleRuntime(roleHost, {
13110
+ async loadSoul() {
13111
+ if (!dependencies.loadNavigatorSoul) throw new Error("Navigator runtime dependencies are not configured");
13112
+ return dependencies.loadNavigatorSoul();
13113
+ }
13114
+ });
12945
13115
  let sessionMergerGitState = dependencies.mergerGitState;
12946
13116
  const merger = createMergerRoleRuntime(roleHost, {
12947
13117
  async loadSoul() {
@@ -13078,6 +13248,8 @@ function createRoleRuntimeExtension(dependencies) {
13078
13248
  countersign,
13079
13249
  gleanerLeft,
13080
13250
  inspector,
13251
+ gatekeeper,
13252
+ navigator,
13081
13253
  merger: async () => {
13082
13254
  if (dependencies.mergerGitState === void 0) {
13083
13255
  sessionMergerGitState = dependencies.createMergerGitState?.(ctx.cwd);
@@ -14456,6 +14628,8 @@ function createGrokRoleRuntimeDependencies(packageRoot) {
14456
14628
  loadDoctorSoul: () => loadMainRoleSessionMaterials("doctor"),
14457
14629
  loadDoctorCase,
14458
14630
  loadInspectorSoul: () => loadMainRoleSessionMaterials("inspector"),
14631
+ loadGatekeeperSoul: () => loadGatekeeperSessionMaterials("gatekeeper"),
14632
+ loadNavigatorSoul: () => loadMainRoleSessionMaterials("navigator"),
14459
14633
  loadNotarySoul: () => loadMainRoleSessionMaterials("notary"),
14460
14634
  loadCountersignSoul: () => loadMainRoleSessionMaterials("countersign"),
14461
14635
  loadGleanerLeftSoul: () => loadMainRoleSessionMaterials("gleaner-left"),