@f5-sales-demo/xcsh 23.2.2 → 23.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +8 -8
- package/src/commands/blindfold-args.ts +16 -3
- package/src/commands/blindfold-help.ts +2 -2
- package/src/commands/blindfold.ts +2 -2
- package/src/internal-urls/api-catalog-index.generated.ts +25301 -25301
- package/src/internal-urls/api-catalog-qmd-index.generated.ts +2 -2
- package/src/internal-urls/api-catalog-resolve.ts +4 -0
- package/src/internal-urls/api-spec-index.generated.ts +1 -1
- package/src/internal-urls/api-spec-resolve.ts +7 -1
- package/src/internal-urls/build-info.generated.ts +9 -9
- package/src/internal-urls/docs-index.generated.ts +2 -1
- package/src/internal-urls/immutable-selection.ts +178 -0
- package/src/internal-urls/public-citation-destinations.generated.ts +2 -2
- package/src/internal-urls/terraform-documentation-assets.generated.ts +28 -28
- package/src/internal-urls/terraform-documentation.ts +1 -1
- package/src/internal-urls/terraform-index.generated.ts +1 -1
- package/src/internal-urls/terraform-property-index.ts +14 -1
- package/src/internal-urls/terraform-property-ranking.ts +10 -3
- package/src/internal-urls/terraform-provider-pin.generated.ts +1 -1
- package/src/prompts/tools/xcsh-api.md +2 -0
- package/src/prompts/tools/xcsh-blindfold.md +1 -1
- package/src/services/blindfold-contract/blindfold-contract-v1.txt +1 -0
- package/src/services/blindfold-contract/lock.json +6 -0
- package/src/services/blindfold-documents.ts +1 -12
- package/src/services/blindfold-ensure.ts +428 -0
- package/src/services/blindfold.ts +16 -6
- package/src/terraform-documentation-smoke.ts +2 -2
- package/src/terraform-port-smoke.ts +15 -0
- package/src/tools/xcsh-api-renderer.ts +16 -0
- package/src/tools/xcsh-api-replacement.ts +524 -0
- package/src/tools/xcsh-api.ts +61 -0
- package/src/tools/xcsh-blindfold.ts +6 -1
package/src/tools/xcsh-api.ts
CHANGED
|
@@ -6,12 +6,14 @@ import type { AgentTool, AgentToolResult } from "@f5-sales-demo/pi-agent-core";
|
|
|
6
6
|
import { prompt } from "@f5-sales-demo/pi-utils";
|
|
7
7
|
import { validateXcshApiCredentials } from "@f5-sales-demo/pi-utils/xcsh-auth";
|
|
8
8
|
import { type Static, Type } from "@sinclair/typebox";
|
|
9
|
+
import { mutationContract, objectValue } from "../internal-urls/immutable-selection";
|
|
9
10
|
import xcshApiDescription from "../prompts/tools/xcsh-api.md" with { type: "text" };
|
|
10
11
|
import { SecretObfuscator } from "../secrets";
|
|
11
12
|
import { type ContextEnv, createContextEnv } from "../services/context-env";
|
|
12
13
|
import { currentContextExecution } from "../services/context-execution";
|
|
13
14
|
import type { ToolSession } from ".";
|
|
14
15
|
import { humanizeResourceType } from "./render-utils";
|
|
16
|
+
import { checkImmutableMutation } from "./xcsh-api-replacement";
|
|
15
17
|
|
|
16
18
|
// Namespace filtering driven by x-f5xc-namespace-profile from enriched API specs.
|
|
17
19
|
|
|
@@ -61,6 +63,16 @@ function loadAllowedNamespaceTypes(domain?: string): ReadonlySet<NamespaceType>
|
|
|
61
63
|
}
|
|
62
64
|
|
|
63
65
|
const xcshApiSchema = Type.Object({
|
|
66
|
+
onImmutableSelectionChange: Type.Optional(
|
|
67
|
+
Type.Literal("recreate", {
|
|
68
|
+
description: "Recreate immutable conversion; downtime and UID/VIP changes.",
|
|
69
|
+
}),
|
|
70
|
+
),
|
|
71
|
+
replacementId: Type.Optional(
|
|
72
|
+
Type.String({
|
|
73
|
+
description: "Resume this cutover.",
|
|
74
|
+
}),
|
|
75
|
+
),
|
|
64
76
|
contextName: Type.Optional(
|
|
65
77
|
Type.String({
|
|
66
78
|
description:
|
|
@@ -101,6 +113,8 @@ const xcshApiSchema = Type.Object({
|
|
|
101
113
|
type XcshApiParams = Static<typeof xcshApiSchema>;
|
|
102
114
|
|
|
103
115
|
export interface XcshApiToolDetails {
|
|
116
|
+
replacementId?: string;
|
|
117
|
+
replacementStage?: string;
|
|
104
118
|
status: number;
|
|
105
119
|
url: string;
|
|
106
120
|
method: string;
|
|
@@ -1062,6 +1076,44 @@ export class XcshApiTool implements AgentTool<typeof xcshApiSchema, XcshApiToolD
|
|
|
1062
1076
|
}
|
|
1063
1077
|
|
|
1064
1078
|
const startMs = performance.now();
|
|
1079
|
+
if (params.method === "PUT") {
|
|
1080
|
+
try {
|
|
1081
|
+
const { API_SPEC_DATA } = require("../internal-urls/api-spec-index.generated") as {
|
|
1082
|
+
API_SPEC_DATA: Readonly<Record<string, unknown>>;
|
|
1083
|
+
};
|
|
1084
|
+
const contract = mutationContract(API_SPEC_DATA, params.method, resolvedPath);
|
|
1085
|
+
if (contract) {
|
|
1086
|
+
const expectedContext = this.#contextEnv.getContextName();
|
|
1087
|
+
const guarded = await checkImmutableMutation({
|
|
1088
|
+
contract,
|
|
1089
|
+
apiBase,
|
|
1090
|
+
contextName: expectedContext,
|
|
1091
|
+
resourcePath: resolvedPath,
|
|
1092
|
+
payload: objectValue(JSON.parse(resolvedPayload ?? "null")),
|
|
1093
|
+
recreate: params.onImmutableSelectionChange === "recreate",
|
|
1094
|
+
replacementId: params.replacementId,
|
|
1095
|
+
headers,
|
|
1096
|
+
signal,
|
|
1097
|
+
stateDir: process.env.XCSH_REPLACEMENT_STATE_DIR,
|
|
1098
|
+
contextMatches: () => {
|
|
1099
|
+
const [base, token] = this.#resolveCredentials();
|
|
1100
|
+
return (
|
|
1101
|
+
base === apiBase && token === apiToken && this.#contextEnv.getContextName() === expectedContext
|
|
1102
|
+
);
|
|
1103
|
+
},
|
|
1104
|
+
});
|
|
1105
|
+
if (guarded) return guarded;
|
|
1106
|
+
} else if (params.replacementId || params.onImmutableSelectionChange)
|
|
1107
|
+
return this.#errorResult("No immutable selection contract matches this request; no mutation was sent.");
|
|
1108
|
+
} catch {
|
|
1109
|
+
return this.#errorResult(
|
|
1110
|
+
"Immutable mutation preflight failed. Check payload selections and embedded schema; no PUT was sent.",
|
|
1111
|
+
);
|
|
1112
|
+
}
|
|
1113
|
+
} else if (params.replacementId || params.onImmutableSelectionChange)
|
|
1114
|
+
return this.#errorResult(
|
|
1115
|
+
"Immutable replacement options require the original PUT resource path; no mutation was sent.",
|
|
1116
|
+
);
|
|
1065
1117
|
try {
|
|
1066
1118
|
let response = await fetch(url, init);
|
|
1067
1119
|
|
|
@@ -1116,6 +1168,15 @@ export class XcshApiTool implements AgentTool<typeof xcshApiSchema, XcshApiToolD
|
|
|
1116
1168
|
|
|
1117
1169
|
const guidance = this.#statusGuidance(response.status);
|
|
1118
1170
|
if (guidance) {
|
|
1171
|
+
if (
|
|
1172
|
+
params.method === "PUT" &&
|
|
1173
|
+
/(?:Https|Http).*?(?:HttpsAutoCert|cannot.*(?:change|replace)|type)/i.test(bodyText)
|
|
1174
|
+
) {
|
|
1175
|
+
return this.#errorResult(
|
|
1176
|
+
`${statusLine}\n\n${bodyText}\n\nPossible immutable selection rejection. Read the schema contract and request recreation only for an explicit conversion; this error does not authorize DELETE.`,
|
|
1177
|
+
detail,
|
|
1178
|
+
);
|
|
1179
|
+
}
|
|
1119
1180
|
let errorCodePrefix = "";
|
|
1120
1181
|
const codeLabel = parsedBody ? XCSH_ERROR_CODES[parsedBody.code as number] : undefined;
|
|
1121
1182
|
if (codeLabel) {
|
|
@@ -11,6 +11,7 @@ import type { ToolSession } from "./index";
|
|
|
11
11
|
export const blindfoldSchema = Type.Object(
|
|
12
12
|
{
|
|
13
13
|
operation: Type.Union(BLINDFOLD_OPERATIONS.map(v => Type.Literal(v))),
|
|
14
|
+
file: Type.Optional(Type.String()),
|
|
14
15
|
input: Type.Optional(Type.String()),
|
|
15
16
|
publicKey: Type.Optional(Type.String()),
|
|
16
17
|
policyDocument: Type.Optional(Type.String()),
|
|
@@ -90,7 +91,11 @@ export class XcshBlindfoldTool implements AgentTool<typeof blindfoldSchema> {
|
|
|
90
91
|
throw new Error("Blindfold context changed; retry against the selected context");
|
|
91
92
|
if (
|
|
92
93
|
this.session.getPlanModeState?.()?.enabled &&
|
|
93
|
-
(args.outputFile ||
|
|
94
|
+
(args.outputFile ||
|
|
95
|
+
args.resultFile ||
|
|
96
|
+
args.operation === "create" ||
|
|
97
|
+
args.operation === "replace" ||
|
|
98
|
+
args.operation === "ensure")
|
|
94
99
|
)
|
|
95
100
|
throw new Error("Plan mode: Blindfold deployments and artifact writes are blocked");
|
|
96
101
|
};
|